Skip to content

Commit

Permalink
MB-49634: Propagate CompactKVStore failure up to caller
Browse files Browse the repository at this point in the history
We shouldn't ignore errors from CompactKVStore when compacting

Change-Id: Ic6023e41d7ae7bbd9c6c7b96ff3b1b412bb23535
Reviewed-on: https://review.couchbase.org/c/kv_engine/+/166325
Tested-by: Build Bot <build@couchbase.com>
Reviewed-by: Dave Rigby <daver@couchbase.com>
  • Loading branch information
BenHuddleston committed Nov 24, 2021
1 parent d79b305 commit da44f93
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 3 additions & 1 deletion engines/ep/src/kvstore/magma-kvstore/magma-kvstore.cc
Expand Up @@ -2167,6 +2167,7 @@ bool MagmaKVStore::compactDBInternal(std::unique_lock<std::mutex>& vbLock,

Status status;
std::unordered_set<CollectionID> purgedCollections;
bool ret = true;
if (dropped.empty()) {
// Compact the entire key range
Slice nullKey;
Expand Down Expand Up @@ -2240,6 +2241,7 @@ bool MagmaKVStore::compactDBInternal(std::unique_lock<std::mutex>& vbLock,
vbid,
cb::UserData{makeDiskDocKey(keySlice).to_string()},
status.String());
ret = false;
continue;
}
// Can't track number of collection items purged properly in the
Expand Down Expand Up @@ -2381,7 +2383,7 @@ bool MagmaKVStore::compactDBInternal(std::unique_lock<std::mutex>& vbLock,
ctx->stats.tombstonesPurged,
ctx->stats.preparesPurged);
}
return true;
return ret;
}

std::unique_ptr<KVFileHandle> MagmaKVStore::makeFileHandle(Vbid vbid) const {
Expand Down
1 change: 1 addition & 0 deletions engines/ep/tests/module_tests/magma_bucket_tests.cc
Expand Up @@ -723,6 +723,7 @@ TEST_P(STParamMagmaBucketTest, FailCompactKVStoreCall) {

// Items all gone, before the fix 1 would remain
EXPECT_EQ(0, vb->getNumTotalItems());
EXPECT_EQ(1, magmaKVStore.getKVStoreStat().numCompactionFailure);
}

INSTANTIATE_TEST_SUITE_P(STParamMagmaBucketTest,
Expand Down

0 comments on commit da44f93

Please sign in to comment.