diff options
author | Geir Storli <geirst@yahoo-inc.com> | 2017-04-24 15:00:16 +0000 |
---|---|---|
committer | Geir Storli <geirst@yahoo-inc.com> | 2017-04-24 15:00:16 +0000 |
commit | 36f93814d9da0eeeaa95c720085c9b2d39dfef92 (patch) | |
tree | e2fb1cd67fd1fb5cbe5114ddcc922eee982b807f | |
parent | dc6964e1e7af53034d3d0eb7061bcb955c90ea80 (diff) |
Calculate prune removed documents interval based on age if set to 0.
3 files changed, 26 insertions, 14 deletions
diff --git a/searchcore/src/tests/proton/proton_config_fetcher/proton_config_fetcher_test.cpp b/searchcore/src/tests/proton/proton_config_fetcher/proton_config_fetcher_test.cpp index b9d8a55b302..904cce00fc4 100644 --- a/searchcore/src/tests/proton/proton_config_fetcher/proton_config_fetcher_test.cpp +++ b/searchcore/src/tests/proton/proton_config_fetcher/proton_config_fetcher_test.cpp @@ -221,16 +221,22 @@ TEST_FFF("require that bootstrap config manager updates config", ConfigTestFixtu ASSERT_TRUE(f1.configEqual(f2.getConfig())); } +DocumentDBConfig::SP +getDocumentDBConfig(ConfigTestFixture &f, DocumentDBConfigManager &mgr) +{ + ConfigRetriever retriever(mgr.createConfigKeySet(), f.context); + mgr.forwardConfig(f.getBootstrapConfig(1)); + mgr.update(retriever.getBootstrapConfigs()); // Cheating, but we only need the configs + return mgr.getConfig(); +} + TEST_FF("require that documentdb config manager subscribes for config", ConfigTestFixture("search"), DocumentDBConfigManager(f1.configId + "/typea", "typea")) { f1.addDocType("typea"); const ConfigKeySet keySet(f2.createConfigKeySet()); ASSERT_EQUAL(8u, keySet.size()); - ConfigRetriever retriever(keySet, f1.context); - f2.forwardConfig(f1.getBootstrapConfig(1)); - f2.update(retriever.getBootstrapConfigs()); // Cheating, but we only need the configs - ASSERT_TRUE(f1.configEqual("typea", f2.getConfig())); + ASSERT_TRUE(f1.configEqual("typea", getDocumentDBConfig(f1, f2))); } TEST_FF("require that documentdb config manager builds schema with imported attribute fields", @@ -241,10 +247,7 @@ TEST_FF("require that documentdb config manager builds schema with imported attr docType->importedFieldsBuilder.attribute.resize(1); docType->importedFieldsBuilder.attribute[0].name = "imported"; - ConfigRetriever retriever(f2.createConfigKeySet(), f1.context); - f2.forwardConfig(f1.getBootstrapConfig(1)); - f2.update(retriever.getBootstrapConfigs()); // Cheating, but we only need the configs - const auto &schema = f2.getConfig()->getSchemaSP(); + const auto &schema = getDocumentDBConfig(f1, f2)->getSchemaSP(); EXPECT_EQUAL(1u, schema->getNumImportedAttributeFields()); EXPECT_EQUAL("imported", schema->getImportedAttributeFields()[0].getName()); } @@ -314,12 +317,19 @@ TEST_FF("require that lid space compaction is disabled for globally distributed DocumentDBConfigManager(f1.configId + "/global", "global")) { f1.addDocType("global", true); - - ConfigRetriever retriever(f2.createConfigKeySet(), f1.context); - f2.forwardConfig(f1.getBootstrapConfig(1)); - f2.update(retriever.getBootstrapConfigs()); // Cheating, but we only need the configs - auto config = f2.getConfig(); + auto config = getDocumentDBConfig(f1, f2); EXPECT_TRUE(config->getMaintenanceConfigSP()->getLidSpaceCompactionConfig().isDisabled()); } +TEST_FF("require that prune removed documents interval can be set based on age", + ConfigTestFixture("test"), + DocumentDBConfigManager(f1.configId + "/test", "test")) +{ + f1.protonBuilder.pruneremoveddocumentsage = 2000; + f1.protonBuilder.pruneremoveddocumentsinterval = 0; + f1.addDocType("test"); + auto config = getDocumentDBConfig(f1, f2); + EXPECT_EQUAL(20, config->getMaintenanceConfigSP()->getPruneRemovedDocumentsConfig().getInterval()); +} + TEST_MAIN() { TEST_RUN_ALL(); } diff --git a/searchcore/src/vespa/searchcore/config/proton.def b/searchcore/src/vespa/searchcore/config/proton.def index 85a02d125e1..a399e203af3 100644 --- a/searchcore/src/vespa/searchcore/config/proton.def +++ b/searchcore/src/vespa/searchcore/config/proton.def @@ -308,6 +308,7 @@ filedistributor.configid reference default="" restart ## Interval between pruning of old removed documents. ## ## Default value is 6 hours (21600 seconds). +## If set to 0, the value is calculated as (pruneremoveddocumentsage / 100) (default 3.36 hours). pruneremoveddocumentsinterval double default=21600.0 ## Age of removed document before it can be pruned. diff --git a/searchcore/src/vespa/searchcore/proton/server/documentdbconfigmanager.cpp b/searchcore/src/vespa/searchcore/proton/server/documentdbconfigmanager.cpp index 0006007caed..52d75e1ff63 100644 --- a/searchcore/src/vespa/searchcore/proton/server/documentdbconfigmanager.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/documentdbconfigmanager.cpp @@ -106,8 +106,9 @@ buildMaintenanceConfig(const BootstrapConfig::SP &bootstrapConfig, if (docTypeName == ddbConfig.inputdoctypename) break; } - double pruneRemovedDocumentsInterval = proton.pruneremoveddocumentsinterval; double pruneRemovedDocumentsAge = proton.pruneremoveddocumentsage; + double pruneRemovedDocumentsInterval = (proton.pruneremoveddocumentsinterval == 0) ? + (pruneRemovedDocumentsAge / 100) : proton.pruneremoveddocumentsinterval; if (index < proton.documentdb.size()) { const DdbConfig &ddbConfig = proton.documentdb[index]; |