Skip to content

Commit 09ad001

Browse files
manudhundidaverigby
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. (cherry picked from commit f9402cb) Change-Id: I8eaf54319014ea4039c74d2cbfab21ef275939fe Reviewed-on: http://review.couchbase.org/64929 Tested-by: buildbot <[email protected]> Reviewed-by: Manu Dhundi <[email protected]> Well-Formed: buildbot <[email protected]>
1 parent 9b19427 commit 09ad001

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
@@ -1442,8 +1442,15 @@ void EventuallyPersistentStore::completeBGFetch(const std::string &key,
14421442
LockHolder hlh = vb->ht.getLockedBucket(key, &bucket_num);
14431443
StoredValue *v = fetchValidValue(vb, key, bucket_num, true);
14441444
if (isMeta) {
1445-
if (v && v->unlocked_restoreMeta(gcb.val.getValue(),
1446-
gcb.val.getStatus(), vb->ht)) {
1445+
if ((v && v->unlocked_restoreMeta(gcb.val.getValue(),
1446+
gcb.val.getStatus(), vb->ht))
1447+
|| ENGINE_KEY_ENOENT == status) {
1448+
/* If ENGINE_KEY_ENOENT is the status from storage and the temp
1449+
key is removed from hash table by the time bgfetch returns
1450+
(in case multiple bgfetch is scheduled for a key), we still
1451+
need to return ENGINE_SUCCESS to the memcached worker thread,
1452+
so that the worker thread can visit the ep-engine and figure
1453+
out the correct flow */
14471454
status = ENGINE_SUCCESS;
14481455
}
14491456
} else {
@@ -1550,7 +1557,14 @@ void EventuallyPersistentStore::completeBGFetchMulti(uint16_t vbId,
15501557
LockHolder blh = vb->ht.getLockedBucket(key, &bucket);
15511558
StoredValue *v = fetchValidValue(vb, key, bucket, true);
15521559
if (bgitem->metaDataOnly) {
1553-
if (v && v->unlocked_restoreMeta(fetchedValue, status, vb->ht)) {
1560+
if ((v && v->unlocked_restoreMeta(fetchedValue, status, vb->ht))
1561+
|| ENGINE_KEY_ENOENT == status) {
1562+
/* If ENGINE_KEY_ENOENT is the status from storage and the temp
1563+
key is removed from hash table by the time bgfetch returns
1564+
(in case multiple bgfetch is scheduled for a key), we still
1565+
need to return ENGINE_SUCCESS to the memcached worker thread,
1566+
so that the worker thread can visit the ep-engine and figure
1567+
out the correct flow */
15541568
status = ENGINE_SUCCESS;
15551569
}
15561570
} else {

0 commit comments

Comments
 (0)