MB-23530: Prevent replace with CAS on deleted item 61/76261/9
authorJames Harrison <00jamesh@gmail.com>
Tue, 4 Apr 2017 16:32:15 +0000 (17:32 +0100)
committerDave Rigby <daver@couchbase.com>
Thu, 13 Apr 2017 14:31:51 +0000 (14:31 +0000)
commit5c17c2ccb77bd244e7a0d144ee5ecd23fc54a341
tree36252a8df511923423b22d06c641c302a04d4821
parentf8d97a05f37e6bc18376c0d1ff913949be70b2bf
MB-23530: Prevent replace with CAS on deleted item

Against an ephemeral bucket or full eviction persistent bucket, a
replace operation could erroneously succeed if the correct CAS value was
given. A replace with a CAS resolves internally to OPERATION_CAS, which
is treated in the same manner as OPERATION_SET.

Prior to this change, we checked if an item was previously deleted if
the CAS did _not_ match, but even if the CAS is /correct/ a replace with
a CAS should fail if the old item is deleted.

The set should only be rejected if the new item is /not/ deleted, to
avoid breaking the delete implementation described in
http://review.couchbase.org/#/c/76119.

Change-Id: Id1eeaeb5326b7a143c7213f07c774f02623bff8d
Reviewed-on: http://review.couchbase.org/76261
Reviewed-by: Daniel Owen <owend@couchbase.com>
Tested-by: Build Bot <build@couchbase.com>
Reviewed-by: Dave Rigby <daver@couchbase.com>
src/vbucket.cc
tests/module_tests/kv_bucket_test.cc