diff options
author | Henning Baldersheim <balder@oath.com> | 2018-11-13 13:24:03 +0100 |
---|---|---|
committer | Henning Baldersheim <balder@oath.com> | 2018-11-13 13:24:03 +0100 |
commit | 4cc373dcca6ae9f2f3d2d0fce7c6f2760c78efd3 (patch) | |
tree | 990991da3b7c87f5e8ba891d3beb3bba36bc836e /searchcore | |
parent | 03c01d5476f9884b31328e8301e5e6e7bf7752ab (diff) |
Add test and fix that repeated reconfigs works for schema changes.
Diffstat (limited to 'searchcore')
-rw-r--r-- | searchcore/src/tests/proton/proton_config_fetcher/proton_config_fetcher_test.cpp | 26 | ||||
-rw-r--r-- | searchcore/src/vespa/searchcore/proton/server/documentdbconfigmanager.cpp | 39 |
2 files changed, 25 insertions, 40 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 2817ddb1b85..d09f8141008 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 @@ -267,16 +267,22 @@ TEST_FF("require that documentdb config manager builds schema with imported attr docType->attributesBuilder.attribute[0].name = "imported"; docType->attributesBuilder.attribute[0].imported = true; docType->attributesBuilder.attribute[1].name = "regular"; - - const auto &schema = getDocumentDBConfig(f1, f2)->getSchemaSP(); - EXPECT_EQUAL(1u, schema->getNumImportedAttributeFields()); - EXPECT_EQUAL("imported", schema->getImportedAttributeFields()[0].getName()); - EXPECT_EQUAL(1u, schema->getNumAttributeFields()); - EXPECT_EQUAL("regular", schema->getAttributeFields()[0].getName()); - - const auto &attrCfg = getDocumentDBConfig(f1, f2)->getAttributesConfig(); - EXPECT_EQUAL(1u, attrCfg.attribute.size()); - EXPECT_EQUAL("regular", attrCfg.attribute[0].name); + docType->summaryBuilder.classes.resize(1); + docType->summaryBuilder.classes[0].id = 1; + docType->summaryBuilder.classes[0].name = "a"; + + for (size_t i(0); i < 3; i++) { + const auto &schema = getDocumentDBConfig(f1, f2)->getSchemaSP(); + EXPECT_EQUAL(1u, schema->getNumImportedAttributeFields()); + EXPECT_EQUAL("imported", schema->getImportedAttributeFields()[0].getName()); + EXPECT_EQUAL(1u, schema->getNumAttributeFields()); + EXPECT_EQUAL("regular", schema->getAttributeFields()[0].getName()); + + const auto &attrCfg = getDocumentDBConfig(f1, f2)->getAttributesConfig(); + EXPECT_EQUAL(1u, attrCfg.attribute.size()); + EXPECT_EQUAL("regular", attrCfg.attribute[0].name); + docType->summaryBuilder.classes[0].id = i+2; + } } TEST_FFF("require that proton config fetcher follows changes to bootstrap", diff --git a/searchcore/src/vespa/searchcore/proton/server/documentdbconfigmanager.cpp b/searchcore/src/vespa/searchcore/proton/server/documentdbconfigmanager.cpp index f2230215c3d..99c4cfb8130 100644 --- a/searchcore/src/vespa/searchcore/proton/server/documentdbconfigmanager.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/documentdbconfigmanager.cpp @@ -234,11 +234,6 @@ DocumentDBConfigManager::update(const ConfigSnapshot &snapshot) RankProfilesConfigSP newRankProfilesConfig; matching::RankingConstants::SP newRankingConstants; IndexschemaConfigSP newIndexschemaConfig; - AttributesConfigSP newAttributesConfig; - SummaryConfigSP newSummaryConfig; - SummarymapConfigSP newSummarymapConfig; - JuniperrcConfigSP newJuniperrcConfig; - ImportedFieldsConfigSP newImportedFieldsConfig; MaintenanceConfigSP oldMaintenanceConfig; MaintenanceConfigSP newMaintenanceConfig; @@ -262,11 +257,6 @@ DocumentDBConfigManager::update(const ConfigSnapshot &snapshot) newRankProfilesConfig = current->getRankProfilesConfigSP(); newRankingConstants = current->getRankingConstantsSP(); newIndexschemaConfig = current->getIndexschemaConfigSP(); - newAttributesConfig = current->getAttributesConfigSP(); - newSummaryConfig = current->getSummaryConfigSP(); - newSummarymapConfig = current->getSummarymapConfigSP(); - newJuniperrcConfig = current->getJuniperrcConfigSP(); - newImportedFieldsConfig = current->getImportedFieldsConfigSP(); oldMaintenanceConfig = current->getMaintenanceConfigSP(); currentGeneration = current->getGeneration(); } @@ -307,31 +297,20 @@ DocumentDBConfigManager::update(const ConfigSnapshot &snapshot) LOG_ABORT("Cannot use bad index schema, validation failed"); } } - if (snapshot.isChanged<AttributesConfig>(_configId, currentGeneration)) { - newAttributesConfig = snapshot.getConfig<AttributesConfig>(_configId); - } - if (snapshot.isChanged<SummaryConfig>(_configId, currentGeneration)) { - newSummaryConfig = snapshot.getConfig<SummaryConfig>(_configId); - } - if (snapshot.isChanged<SummarymapConfig>(_configId, currentGeneration)) { - newSummarymapConfig = snapshot.getConfig<SummarymapConfig>(_configId); - } - if (snapshot.isChanged<JuniperrcConfig>(_configId, currentGeneration)) { - newJuniperrcConfig = snapshot.getConfig<JuniperrcConfig>(_configId); - } - if (snapshot.isChanged<ImportedFieldsConfig>(_configId, currentGeneration)) { - newImportedFieldsConfig = snapshot.getConfig<ImportedFieldsConfig>(_configId); - } + AttributesConfigSP newAttributesConfig = snapshot.getConfig<AttributesConfig>(_configId); + SummaryConfigSP newSummaryConfig = snapshot.getConfig<SummaryConfig>(_configId); + SummarymapConfigSP newSummarymapConfig = snapshot.getConfig<SummarymapConfig>(_configId); + JuniperrcConfigSP newJuniperrcConfig = snapshot.getConfig<JuniperrcConfig>(_configId); + ImportedFieldsConfigSP newImportedFieldsConfig = snapshot.getConfig<ImportedFieldsConfig>(_configId); Schema::SP schema(buildSchema(*newAttributesConfig, *newSummaryConfig, *newIndexschemaConfig)); newMaintenanceConfig = buildMaintenanceConfig(_bootstrapConfig, _docTypeName); search::LogDocumentStore::Config storeConfig = buildStoreConfig(_bootstrapConfig->getProtonConfig(), _bootstrapConfig->getHwInfo()); - if (newMaintenanceConfig && oldMaintenanceConfig && *newMaintenanceConfig == *oldMaintenanceConfig) { + if (newMaintenanceConfig && oldMaintenanceConfig && (*newMaintenanceConfig == *oldMaintenanceConfig)) { newMaintenanceConfig = oldMaintenanceConfig; } - DocumentDBConfig::SP newSnapshot( - new DocumentDBConfig(generation, + auto newSnapshot = std::make_shared<DocumentDBConfig>(generation, newRankProfilesConfig, newRankingConstants, newIndexschemaConfig, @@ -347,7 +326,7 @@ DocumentDBConfigManager::update(const ConfigSnapshot &snapshot) newMaintenanceConfig, storeConfig, _configId, - _docTypeName)); + _docTypeName); assert(newSnapshot->valid()); { std::lock_guard<std::mutex> lock(_pendingConfigMutex); @@ -366,7 +345,7 @@ DocumentDBConfigManager(const vespalib::string &configId, const vespalib::string _pendingConfigMutex() { } -DocumentDBConfigManager::~DocumentDBConfigManager() { } +DocumentDBConfigManager::~DocumentDBConfigManager() = default; DocumentDBConfig::SP DocumentDBConfigManager::getConfig() const { |