MB-23976: Return updated CAS from TOUCH command 61/76961/4
authorDave Rigby <daver@couchbase.com>
Tue, 18 Apr 2017 16:53:16 +0000 (17:53 +0100)
committerDave Rigby <daver@couchbase.com>
Wed, 19 Apr 2017 13:10:58 +0000 (13:10 +0000)
The TOUCH command was incorrectly returning the CAS *before* the
document was updated, instead of the CAS value after the update.

Change-Id: I9f6b1dd08c67f09d3191c4d3061d63c96d894af7
Reviewed-on: http://review.couchbase.org/76961
Reviewed-by: Trond Norbye <trond.norbye@gmail.com>
Tested-by: Build Bot <build@couchbase.com>
src/vbucket.cc
tests/ep_testsuite_basic.cc

index 33c48cb..306948a 100644 (file)
@@ -1434,6 +1434,7 @@ GetValue VBucket::getAndUpdateTtl(const DocKey& key,
 
         if (exptime_mutated) {
             VBNotifyCtx notifyCtx = queueDirty(*v);
+            rv.getValue()->setCas(v->getCas());
             // we unlock ht lock here because we want to avoid potential lock
             // inversions arising from notifyNewSeqno() call
             hbl.getHTLock().unlock();
index 11a37d0..4bf313c 100644 (file)
@@ -1017,6 +1017,7 @@ static enum test_result test_touch(ENGINE_HANDLE *h, ENGINE_HANDLE_V1 *h1) {
     touch(h, h1, "mykey", 0, (time(NULL) + 10));
     checkeq(PROTOCOL_BINARY_RESPONSE_SUCCESS, last_status.load(),
             "touch mykey");
+    check(last_cas != curr_cas, "touch should have returned an updated CAS");
 
     check(get_meta(h, h1, "mykey"), "Get meta failed");
     checkeq(PROTOCOL_BINARY_RESPONSE_SUCCESS, last_status.load(),