@@ -321,6 +321,49 @@ TEST_P(EPStoreEvictionTest, SetWithMeta_ReplaceNonResident) {
321321 }
322322}
323323
324+ // Deleted-with-Value Tests ///////////////////////////////////////////////////
325+
326+ TEST_P (EPStoreEvictionTest, DeletedValue) {
327+ // Create a deleted item which has a value, then evict it.
328+ auto key = makeStoredDocKey (" key" );
329+ auto item = make_item (vbid, key, " deleted value" );
330+ item.setDeleted ();
331+ EXPECT_EQ (ENGINE_SUCCESS, store->set (item, nullptr ));
332+
333+ // The act of flushing will remove the item from the HashTable.
334+ flush_vbucket_to_disk (vbid);
335+ EXPECT_EQ (0 , store->getVBucket (vbid)->getNumItems ());
336+
337+ // Setup a lambda for how we want to call get (saves repeating the
338+ // same arguments for each instance below).
339+ auto do_get = [this , &key]() {
340+ auto options = get_options_t (GET_DELETED_VALUE | QUEUE_BG_FETCH);
341+ return store->get (key, vbid, cookie, options);
342+ };
343+
344+ // Try to get the Deleted-with-value key. This should return EWOULDBLOCK
345+ // (as the Deleted value is not resident).
346+ EXPECT_EQ (ENGINE_EWOULDBLOCK, do_get ().getStatus ())
347+ << " Expected to need to go to disk to get Deleted-with-value key" ;
348+
349+ // Try a second time - this should detect the already-created temp
350+ // item, and re-schedule the bgfetch.
351+ EXPECT_EQ (ENGINE_EWOULDBLOCK, do_get ().getStatus ())
352+ << " Expected to need to go to disk to get Deleted-with-value key "
353+ " (try 2)" ;
354+
355+ // Manually run the BGFetcher task; to fetch the two outstanding
356+ // requests (for the same key).
357+ MockGlobalTask mockTask (engine->getTaskable (), TaskId::MultiBGFetcherTask);
358+ store->getVBucket (vbid)->getShard ()->getBgFetcher ()->run (&mockTask);
359+
360+ auto result = do_get ();
361+ EXPECT_EQ (ENGINE_SUCCESS, result.getStatus ())
362+ << " Expected to get Deleted-with-value for evicted key after "
363+ " notify_IO_complete" ;
364+ EXPECT_EQ (" deleted value" , result.item ->getValue ()->to_s ());
365+ }
366+
324367// Test to ensure all pendingBGfetches are deleted when the
325368// VBucketMemoryDeletionTask is run
326369TEST_P (EPStoreEvictionTest, MB_21976) {
0 commit comments