Skip to content

Commit

Permalink
MB-41857: Use given ops in openDbForRead
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
BenHuddleston committed Oct 8, 2020
1 parent 7d59b44 commit 5cf5a80
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
3 changes: 2 additions & 1 deletion engines/ep/src/couch-kvstore/couch-kvstore.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2028,7 +2028,8 @@ CouchKVStore::OpenForReadResult CouchKVStore::openDbForRead(
auto result = openSpecificDB(vbucketId,
fileRev,
handle->getDbHolder(),
COUCHSTORE_OPEN_FLAG_RDONLY);
COUCHSTORE_OPEN_FLAG_RDONLY,
ops);
if (result != COUCHSTORE_SUCCESS) {
return {result, std::move(handle)};
}
Expand Down
15 changes: 15 additions & 0 deletions engines/ep/tests/module_tests/couch-kvstore_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2117,3 +2117,18 @@ TEST_F(CouchstoreTest, CacheLimitBumpedOnOldDbCloseDuringCompaction) {
EXPECT_TRUE(kvstore->compactDB(lock, ctx));
EXPECT_EQ(5, CouchKVStoreFileCache::get().getHandle()->capacity());
}

TEST_F(CouchstoreTest, CompactionUsesCorrectFileOps) {
CouchKVStoreFileCache::get().getHandle()->resize(5);
CompactionConfig config;
auto ctx = std::make_shared<CompactionContext>(config, 0);

std::mutex mutex;
std::unique_lock<std::mutex> lock(mutex);
EXPECT_EQ(5, CouchKVStoreFileCache::get().getHandle()->capacity());

EXPECT_TRUE(kvstore->compactDB(lock, ctx));
EXPECT_EQ(5, CouchKVStoreFileCache::get().getHandle()->capacity());
auto compactStats = kvstore->getKVStoreStat().fsStatsCompaction;
EXPECT_NE(0, compactStats.readCountHisto.getValueCount());
}

0 comments on commit 5cf5a80

Please sign in to comment.