summaryrefslogtreecommitdiffstats
path: root/searchcore
diff options
context:
space:
mode:
authorTor Egge <Tor.Egge@broadpark.no>2021-03-29 12:39:30 +0200
committerTor Egge <Tor.Egge@broadpark.no>2021-03-29 12:47:22 +0200
commita2e063d3394e1eb32b8899daebe3a222f5db4cdb (patch)
treeb2e71e6272269ddc9c7158c27cd3a3600e55db2c /searchcore
parentf9c63106a9800731b272aaf9c1be32513b303c87 (diff)
Control document meta store compaction pace.
Diffstat (limited to 'searchcore')
-rw-r--r--searchcore/src/tests/proton/documentmetastore/documentmetastore_test.cpp44
-rw-r--r--searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastore.cpp3
2 files changed, 39 insertions, 8 deletions
diff --git a/searchcore/src/tests/proton/documentmetastore/documentmetastore_test.cpp b/searchcore/src/tests/proton/documentmetastore/documentmetastore_test.cpp
index 84dadff0104..5dd6f0ff10f 100644
--- a/searchcore/src/tests/proton/documentmetastore/documentmetastore_test.cpp
+++ b/searchcore/src/tests/proton/documentmetastore/documentmetastore_test.cpp
@@ -2091,6 +2091,16 @@ TEST(DocumentMetaStoreTest, call_to_remove_is_notified)
EXPECT_EQ(1, listener->remove_cnt);
}
+namespace {
+
+void try_compact_document_meta_store(DocumentMetaStore &dms)
+{
+ dms.removeAllOldGenerations();
+ dms.commit(true);
+}
+
+}
+
TEST(DocumentMetaStoreTest, gid_to_lid_map_can_be_compacted)
{
auto dms = std::make_shared<DocumentMetaStore>(createBucketDB());
@@ -2106,17 +2116,35 @@ TEST(DocumentMetaStoreTest, gid_to_lid_map_can_be_compacted)
auto status_before = dms->getStatus();
EXPECT_LT(0, status_before.getOnHold());
guard = AttributeGuard();
- dms->removeAllOldGenerations();
- dms->commit(true);
- auto status_middle = dms->getStatus();
- EXPECT_LT(status_before.getDead(), status_middle.getDead());
- EXPECT_EQ(0, status_middle.getOnHold());
- for (uint32_t i = 0; i < 15; ++i) {
- dms->commit(true);
+ try_compact_document_meta_store(*dms);
+ auto status_early = dms->getStatus();
+ EXPECT_LT(status_before.getDead(), status_early.getDead());
+ EXPECT_EQ(0, status_early.getOnHold());
+ bool compaction_done = false;
+ for (uint32_t i = 0; i < 15 && !compaction_done; ++i) {
+ AttributeGuard guard2(dms);
+ auto status_loop_iteration_start = dms->getStatus();
+ try_compact_document_meta_store(*dms);
+ try_compact_document_meta_store(*dms);
+ auto status_second = dms->getStatus();
+ if (i > 0) {
+ EXPECT_GT(status_before.getUsed(), status_second.getUsed());
+ }
+ EXPECT_GT(status_early.getDead(), status_second.getDead());
+ try_compact_document_meta_store(*dms);
+ auto status_third = dms->getStatus();
+ EXPECT_EQ(status_second.getDead(), status_third.getDead());
+ EXPECT_EQ(status_second.getUsed(), status_third.getUsed());
+ EXPECT_EQ(status_second.getOnHold(), status_third.getOnHold());
+ EXPECT_GE(status_loop_iteration_start.getDead(), status_third.getDead());
+ if (status_loop_iteration_start.getDead() == status_third.getDead()) {
+ compaction_done = true;
+ }
}
+ EXPECT_TRUE(compaction_done);
auto status_after = dms->getStatus();
EXPECT_GT(status_before.getUsed(), status_after.getUsed());
- EXPECT_GT(status_middle.getDead(), status_after.getDead());
+ EXPECT_GT(status_early.getDead(), status_after.getDead());
EXPECT_EQ(0, status_after.getOnHold());
}
diff --git a/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastore.cpp b/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastore.cpp
index 25c0e29fbda..d0cada2224f 100644
--- a/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastore.cpp
+++ b/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastore.cpp
@@ -209,6 +209,9 @@ constexpr size_t DEAD_BYTES_SLACK = 0x10000u;
bool
DocumentMetaStore::consider_compact_gid_to_lid_map()
{
+ if (_gidToLidMap.getAllocator().getNodeStore().has_held_buffers()) {
+ return false;
+ }
auto &compaction_strategy = getConfig().getCompactionStrategy();
size_t used_bytes = _cached_gid_to_lid_map_memory_usage.usedBytes();
size_t dead_bytes = _cached_gid_to_lid_map_memory_usage.deadBytes();