MB-24430: Set the value correctly for an expired item in memory 20/78220/3
authorSriram Ganesan <sriram@couchbase.com>
Wed, 17 May 2017 00:19:20 +0000 (17:19 -0700)
committerDave Rigby <daver@couchbase.com>
Thu, 18 May 2017 09:16:45 +0000 (09:16 +0000)
If an item is found to be expired in the hash table, then its value
needs to be set correctly. For example, in case the item contains
xattrs, the system xattrs will be retained in the value and hence
needs to be set correctly

Change-Id: I99a54ca82feb837f530b18eb3f245a9d92f12369
Reviewed-on: http://review.couchbase.org/78220
Tested-by: Build Bot <build@couchbase.com>
Reviewed-by: Dave Rigby <daver@couchbase.com>
src/vbucket.cc
tests/module_tests/evp_store_single_threaded_test.cc
tests/module_tests/evp_store_test.cc

index 75455bf..bd2b7d0 100644 (file)
@@ -1325,6 +1325,7 @@ void VBucket::deleteExpiredItem(const Item& it,
             }
         } else if (v->isExpired(startTime) && !v->isDeleted()) {
             VBNotifyCtx notifyCtx;
+            ht.setValue(it, *v);
             std::tie(std::ignore, std::ignore, notifyCtx) =
                     processExpiredItem(hbl, *v);
             // we unlock ht lock here because we want to avoid potential lock
index 62114c3..ea535ab 100644 (file)
@@ -1097,9 +1097,13 @@ TEST_F(SingleThreadedEPBucketTest, pre_expiry_xattrs) {
     cb::xattr::Blob new_blob(value_buf);
 
     const std::string& cas_str{"{\"cas\":\"0xdeadbeefcafefeed\"}"};
-    const std::string& sync_str = to_string(blob.get(to_const_byte_buffer("_sync")));
+    const std::string& sync_str = to_string(new_blob.get(to_const_byte_buffer("_sync")));
 
     EXPECT_EQ(cas_str, sync_str) << "Unexpected system xattrs";
+    EXPECT_TRUE(new_blob.get(to_const_byte_buffer("user")).empty()) <<
+              "The user attribute should be gone";
+    EXPECT_TRUE(new_blob.get(to_const_byte_buffer("meta")).empty()) <<
+              "The meta attribute should be gone";
 
     kvbucket.getMetaData(makeStoredDocKey("key"), vbid, cookie, metadata,
                          deleted, datatype);
index 82d6761..9f9c060 100644 (file)
@@ -458,6 +458,8 @@ TEST_P(EPStoreEvictionTest, xattrExpiryOnFullyEvictedItem) {
     const std::string& meta_str = to_string(new_blob.get(to_const_byte_buffer("_meta")));
 
     EXPECT_EQ(rev_str, meta_str) << "Unexpected system xattrs";
+    EXPECT_TRUE(new_blob.get(to_const_byte_buffer("foo")).empty()) <<
+                "The foo attribute should be gone";
 }
 
 // Test cases which run in both Full and Value eviction