Skip to content

Commit ac8385e

Browse files
jimwwalkerdaverigby
authored andcommitted
MB-35546: Return CAS from durable delete
Use the same technique from the set case where the engine specific token is the CAS of the item. Change-Id: I558b4b9071f5564ac9959dccf71ecc87c04bd0c0 Reviewed-on: http://review.couchbase.org/113632 Reviewed-by: Trond Norbye <trond.norbye@couchbase.com> Reviewed-by: Dave Rigby <daver@couchbase.com> Tested-by: Build Bot <build@couchbase.com>
1 parent f21b690 commit ac8385e

File tree

3 files changed

+17
-18
lines changed

3 files changed

+17
-18
lines changed

engines/ep/src/ep_engine.cc

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ ENGINE_ERROR_CODE EventuallyPersistentEngine::remove(
223223
const boost::optional<cb::durability::Requirements>& durability,
224224
mutation_descr_t& mut_info) {
225225
return acquireEngine(this)->itemDelete(
226-
cookie, key, cas, vbucket, durability, nullptr, mut_info);
226+
cookie, key, cas, vbucket, durability, mut_info);
227227
}
228228

229229
void EventuallyPersistentEngine::release(gsl::not_null<item*> itm) {
@@ -2140,23 +2140,27 @@ ENGINE_ERROR_CODE EventuallyPersistentEngine::itemDelete(
21402140
uint64_t& cas,
21412141
Vbid vbucket,
21422142
boost::optional<cb::durability::Requirements> durability,
2143-
ItemMetaData* item_meta,
21442143
mutation_descr_t& mut_info) {
21452144
// Check if this is a in-progress durable delete which has now completed -
21462145
// (see 'case EWOULDBLOCK' at the end of this function where we record
21472146
// the fact we must block the client until the SycnWrite is durable).
2148-
if (durability && getEngineSpecific(cookie) != nullptr) {
2149-
// Non-null means this is the second call to this function after
2150-
// the SyncWrite has completed.
2151-
// Clear the engineSpecific, and return SUCCESS.
2152-
storeEngineSpecific(cookie, nullptr);
2153-
// @todo-durability - add support for non-sucesss (e.g. Aborted) when
2154-
// we support non-successful completions of SyncWrites.
2155-
return ENGINE_SUCCESS;
2147+
if (durability) {
2148+
void* deletedCas = getEngineSpecific(cookie);
2149+
if (deletedCas) {
2150+
// Non-null means this is the second call to this function after
2151+
// the SyncWrite has completed.
2152+
// Clear the engineSpecific, and return SUCCESS.
2153+
storeEngineSpecific(cookie, nullptr);
2154+
2155+
cas = reinterpret_cast<uint64_t>(deletedCas);
2156+
// @todo-durability - add support for non-sucesss (e.g. Aborted)
2157+
// when we support non-successful completions of SyncWrites.
2158+
return ENGINE_SUCCESS;
2159+
}
21562160
}
21572161

21582162
ENGINE_ERROR_CODE ret = kvBucket->deleteItem(
2159-
key, cas, vbucket, cookie, durability, item_meta, mut_info);
2163+
key, cas, vbucket, cookie, durability, nullptr, mut_info);
21602164

21612165
switch (ret) {
21622166
case ENGINE_KEY_ENOENT:
@@ -2174,7 +2178,7 @@ ENGINE_ERROR_CODE EventuallyPersistentEngine::itemDelete(
21742178
// the result of the SyncWrite (see call to getEngineSpecific at
21752179
// the head of this function).
21762180
// (just store non-null value to indicate this).
2177-
storeEngineSpecific(cookie, reinterpret_cast<void*>(0x1));
2181+
storeEngineSpecific(cookie, reinterpret_cast<void*>(cas));
21782182
}
21792183
break;
21802184

engines/ep/src/ep_engine.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -409,9 +409,6 @@ class EventuallyPersistentEngine : public EngineIface, public DcpIface {
409409
* back to the client
410410
* @param vbucket vbucket id to which the deleted key corresponds to
411411
* @param durability Optional durability requirements for this deletion.
412-
* @param item_meta pointer to item meta data that needs to be
413-
* as a result the delete. A NULL pointer indicates
414-
* that no meta data needs to be returned.
415412
* @param mut_info pointer to the mutation info that resulted from
416413
* the delete.
417414
*
@@ -424,7 +421,6 @@ class EventuallyPersistentEngine : public EngineIface, public DcpIface {
424421
uint64_t& cas,
425422
Vbid vbucket,
426423
boost::optional<cb::durability::Requirements> durability,
427-
ItemMetaData* item_meta,
428424
mutation_descr_t& mut_info);
429425

430426
void itemRelease(item* itm);

tests/testapp_cluster/durability_tests.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,7 @@ TEST_F(DurabilityTest, Prepend) {
108108
mutate(*getConnection(), "Prepend", MutationType::Prepend);
109109
}
110110

111-
// This is blocked by MB-35546
112-
TEST_F(DurabilityTest, DISABLED_Delete) {
111+
TEST_F(DurabilityTest, Delete) {
113112
auto conn = getConnection();
114113
const auto old =
115114
conn->store("Delete", Vbid{0}, "", cb::mcbp::Datatype::Raw);

0 commit comments

Comments
 (0)