Skip to content

Commit

Permalink
MB-56094: Update CM::numItems at ItemExpel
Browse files Browse the repository at this point in the history
Quantity correctly updated in the CheckpointRemoval path, but we missed
to update it when items are released in the Expel path.

Change-Id: Ic05cbb3b9c98c6c9073b9b6f74fdfd6604cdcb74
Reviewed-on: https://review.couchbase.org/c/kv_engine/+/188832
Tested-by: Paolo Cocchi <paolo.cocchi@couchbase.com>
Reviewed-by: Vesko Karaganev <vesko.karaganev@couchbase.com>
  • Loading branch information
paolococchi committed Mar 29, 2023
1 parent 625fba8 commit 9e27797
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions engines/ep/src/checkpoint_manager.cc
Expand Up @@ -687,6 +687,7 @@ CheckpointManager::expelUnreferencedCheckpointItems() {
}

stats.itemsExpelledFromCheckpoints.fetch_add(numItemsExpelled);
numItems.fetch_sub(numItemsExpelled);

// queueLock already released here, O(N) deallocation is lock-free
const auto queuedItemsMemReleased = extractRes.deleteItems();
Expand Down
9 changes: 6 additions & 3 deletions engines/ep/tests/module_tests/checkpoint_test.cc
Expand Up @@ -2216,7 +2216,9 @@ void CheckpointTest::testExpelCheckpointItems() {
* 1002 - 2nd item (key1) <<<<<<< persistenceCursor
* 1003 - 3rd item (key2)
*/
EXPECT_EQ(1 + itemCount, manager->getNumOpenChkItems());
const size_t expectedNumItemsPre = 1 + itemCount;
EXPECT_EQ(expectedNumItemsPre, manager->getNumOpenChkItems());
EXPECT_EQ(expectedNumItemsPre, manager->getNumItems());

const auto expelResult = manager->expelUnreferencedCheckpointItems();
EXPECT_EQ(2, expelResult.count);
Expand All @@ -2240,8 +2242,9 @@ void CheckpointTest::testExpelCheckpointItems() {
}

// 1 mutation removed from checkpoint
EXPECT_EQ(1 + (itemCount - expelResult.count),
manager->getNumOpenChkItems());
const size_t expectedNumItemsPost = 1 + (itemCount - expelResult.count);
EXPECT_EQ(expectedNumItemsPost, manager->getNumOpenChkItems());
EXPECT_EQ(expectedNumItemsPost, manager->getNumItems());

// Try to register a DCP replication cursor from 1001 - an expelled item.
std::string dcp_cursor1(DCP_CURSOR_PREFIX + std::to_string(1));
Expand Down

0 comments on commit 9e27797

Please sign in to comment.