Skip to content

Commit f9402cb

Browse files
manudhundichiyoung
authored andcommitted
MB-14859: Handle quick successive BG Fetch of a key interleaved with exp pager
If two bgfetch are scheduled for a non existing key, and one bgfetch completes and marks the key as non existant in the hash table, and subsequently expiry pager removes it from the hash table before the second bgfetch completes, we need to handle the case appropriately in the complete bgfetch code as notify the memcached with appropriate return value. Change-Id: I8eaf54319014ea4039c74d2cbfab21ef275939fe Reviewed-on: http://review.couchbase.org/52445 Tested-by: buildbot <[email protected]> Reviewed-by: Chiyoung Seo <[email protected]>
1 parent e1ce844 commit f9402cb

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

src/ep.cc

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1607,8 +1607,15 @@ void EventuallyPersistentStore::completeBGFetch(const std::string &key,
16071607
LockHolder hlh = vb->ht.getLockedBucket(key, &bucket_num);
16081608
StoredValue *v = fetchValidValue(vb, key, bucket_num, true);
16091609
if (isMeta) {
1610-
if (v && v->unlocked_restoreMeta(gcb.val.getValue(),
1611-
gcb.val.getStatus(), vb->ht)) {
1610+
if ((v && v->unlocked_restoreMeta(gcb.val.getValue(),
1611+
gcb.val.getStatus(), vb->ht))
1612+
|| ENGINE_KEY_ENOENT == status) {
1613+
/* If ENGINE_KEY_ENOENT is the status from storage and the temp
1614+
key is removed from hash table by the time bgfetch returns
1615+
(in case multiple bgfetch is scheduled for a key), we still
1616+
need to return ENGINE_SUCCESS to the memcached worker thread,
1617+
so that the worker thread can visit the ep-engine and figure
1618+
out the correct flow */
16121619
status = ENGINE_SUCCESS;
16131620
}
16141621
} else {
@@ -1703,7 +1710,14 @@ void EventuallyPersistentStore::completeBGFetchMulti(uint16_t vbId,
17031710
LockHolder blh = vb->ht.getLockedBucket(key, &bucket);
17041711
StoredValue *v = fetchValidValue(vb, key, bucket, true);
17051712
if (bgitem->metaDataOnly) {
1706-
if (v && v->unlocked_restoreMeta(fetchedValue, status, vb->ht)) {
1713+
if ((v && v->unlocked_restoreMeta(fetchedValue, status, vb->ht))
1714+
|| ENGINE_KEY_ENOENT == status) {
1715+
/* If ENGINE_KEY_ENOENT is the status from storage and the temp
1716+
key is removed from hash table by the time bgfetch returns
1717+
(in case multiple bgfetch is scheduled for a key), we still
1718+
need to return ENGINE_SUCCESS to the memcached worker thread,
1719+
so that the worker thread can visit the ep-engine and figure
1720+
out the correct flow */
17071721
status = ENGINE_SUCCESS;
17081722
}
17091723
} else {

0 commit comments

Comments
 (0)