Skip to content

Commit 5cf5a80

Browse files
committed
MB-41857: Use given ops in openDbForRead
In CouchKVStore::openDbForRead we ignore the ops given and don't pass them to openSpecificDb. This means we don't track stats at compaction correctly. Correct this by using the supplied ops. Change-Id: Ia77e10bc1a7b6c4a479d7c935561590a4713601c Reviewed-on: http://review.couchbase.org/c/kv_engine/+/137574 Reviewed-by: Jim Walker <[email protected]> Tested-by: Build Bot <[email protected]>
1 parent 7d59b44 commit 5cf5a80

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

engines/ep/src/couch-kvstore/couch-kvstore.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2028,7 +2028,8 @@ CouchKVStore::OpenForReadResult CouchKVStore::openDbForRead(
20282028
auto result = openSpecificDB(vbucketId,
20292029
fileRev,
20302030
handle->getDbHolder(),
2031-
COUCHSTORE_OPEN_FLAG_RDONLY);
2031+
COUCHSTORE_OPEN_FLAG_RDONLY,
2032+
ops);
20322033
if (result != COUCHSTORE_SUCCESS) {
20332034
return {result, std::move(handle)};
20342035
}

engines/ep/tests/module_tests/couch-kvstore_test.cc

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2117,3 +2117,18 @@ TEST_F(CouchstoreTest, CacheLimitBumpedOnOldDbCloseDuringCompaction) {
21172117
EXPECT_TRUE(kvstore->compactDB(lock, ctx));
21182118
EXPECT_EQ(5, CouchKVStoreFileCache::get().getHandle()->capacity());
21192119
}
2120+
2121+
TEST_F(CouchstoreTest, CompactionUsesCorrectFileOps) {
2122+
CouchKVStoreFileCache::get().getHandle()->resize(5);
2123+
CompactionConfig config;
2124+
auto ctx = std::make_shared<CompactionContext>(config, 0);
2125+
2126+
std::mutex mutex;
2127+
std::unique_lock<std::mutex> lock(mutex);
2128+
EXPECT_EQ(5, CouchKVStoreFileCache::get().getHandle()->capacity());
2129+
2130+
EXPECT_TRUE(kvstore->compactDB(lock, ctx));
2131+
EXPECT_EQ(5, CouchKVStoreFileCache::get().getHandle()->capacity());
2132+
auto compactStats = kvstore->getKVStoreStat().fsStatsCompaction;
2133+
EXPECT_NE(0, compactStats.readCountHisto.getValueCount());
2134+
}

0 commit comments

Comments
 (0)