MB-23906: Delete-with-value: Fix count of deleted items 20/76120/15
authorDave Rigby <daver@couchbase.com>
Fri, 31 Mar 2017 10:46:13 +0000 (11:46 +0100)
committerDave Rigby <daver@couchbase.com>
Wed, 19 Apr 2017 07:35:26 +0000 (07:35 +0000)
commita8878115a646ca5948d64ee947023a92b1a962b0
tree144d528b5f3b822bb0e826637e09b0606c1327e5
parentbc90d68840b12e83f69e6b0e6b142fcc55033195
MB-23906: Delete-with-value: Fix count of deleted items

Prior to Spock, the valid state transitions for StoredValues (relating
to deletion) were:

    /---\
    |   |
    |   V
    Alive --------> Deleted
          <--------

With the advent of Deleted Bodies for system XATTRs, Deleted SVs can
optionally have a value (Blob) associated with them, which can be
changed (or removed) without going back to Alive:

    /---\              /---\
    |   |              |   |
    \   V              \   V
    Alive -------->   Deleted   ----------> Deleted
      ^   <--------  with-value <---------- no-value
      |                                         |
      |                                         |
      \-----------------------------------------/

Given that Deleted-with-Value and Alive both are moved-to using
updateStoredValue(), we need to handle increasing numDeletedItems in
additional code paths - specifically whenever the value changes.

Fix this in HashTable::unlocked_updateStoredValue, and add tests for
these cases to the Delete-with-value tests.

Change-Id: Id9224ed0e66d0298c0f73621fedba3af1fe62e86
Reviewed-on: http://review.couchbase.org/76120
Reviewed-by: Manu Dhundi <manu@couchbase.com>
Tested-by: Build Bot <build@couchbase.com>
src/hash_table.cc
tests/ep_testsuite_basic.cc
tests/module_tests/vbucket_test.cc