Skip to content

Commit 9df3480

Browse files
jimwwalkerdaverigby
authored andcommitted
MB-29816: Add test-case to show how get can be impacted
Simple test which has 1 key stored and then does a get of the stored key plus a get of a non-existent key. We disable bloom-filters to ensure the non-existent GET turns into a bgFetch Change-Id: I35d4bbb7ab3cc0889beb14f2aa02c3e160334eb1 Reviewed-on: http://review.couchbase.org/95621 Well-Formed: Build Bot <[email protected]> Reviewed-by: Tim Bradgate <[email protected]> Tested-by: Build Bot <[email protected]> Reviewed-by: Dave Rigby <[email protected]>
1 parent 3c0339f commit 9df3480

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

engines/ep/tests/module_tests/evp_store_test.cc

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -996,6 +996,46 @@ TEST_P(EPStoreEvictionBloomOnOffTest, store_if_fe_interleave) {
996996
.status);
997997
}
998998

999+
// Run in FE only with bloom filter off, so all gets turn into bgFetches
1000+
class EPStoreFullEvictionNoBloomFIlterTest : public EPBucketTest {
1001+
void SetUp() override {
1002+
config_string += std::string{"item_eviction_policy=full_eviction;"
1003+
"bfilter_enabled=false"};
1004+
EPBucketTest::SetUp();
1005+
1006+
// Have all the objects, activate vBucket zero so we can store data.
1007+
store->setVBucketState(vbid, vbucket_state_active, false);
1008+
}
1009+
};
1010+
1011+
// Demonstrate the couchstore issue affects get - if we have multiple gets in
1012+
// one batch and the keys are crafted in such a way, we will skip out the get
1013+
// of the one key which really does exist.
1014+
TEST_F(EPStoreFullEvictionNoBloomFIlterTest, MB_29816) {
1015+
auto key = makeStoredDocKey("005");
1016+
store_item(vbid, key, "value");
1017+
flush_vbucket_to_disk(vbid);
1018+
evict_key(vbid, key);
1019+
1020+
auto key2 = makeStoredDocKey("004");
1021+
get_options_t options = static_cast<get_options_t>(
1022+
QUEUE_BG_FETCH | HONOR_STATES | TRACK_REFERENCE | DELETE_TEMP |
1023+
HIDE_LOCKED_CAS | TRACK_STATISTICS);
1024+
auto gv = store->get(key, vbid, cookie, options);
1025+
EXPECT_EQ(ENGINE_EWOULDBLOCK, gv.getStatus());
1026+
gv = store->get(key2, vbid, cookie, options);
1027+
EXPECT_EQ(ENGINE_EWOULDBLOCK, gv.getStatus());
1028+
1029+
runBGFetcherTask();
1030+
1031+
// Get the keys again
1032+
gv = store->get(key, vbid, cookie, options);
1033+
ASSERT_EQ(ENGINE_SUCCESS, gv.getStatus()) << "key:005 should of been found";
1034+
1035+
gv = store->get(key2, vbid, cookie, options);
1036+
ASSERT_EQ(ENGINE_KEY_ENOENT, gv.getStatus());
1037+
}
1038+
9991039
struct PrintToStringCombinedName {
10001040
std::string operator()(
10011041
const ::testing::TestParamInfo<::testing::tuple<std::string, bool>>&

0 commit comments

Comments
 (0)