From 1acb5e0824379ac8869fd31d231306a826e2675c Mon Sep 17 00:00:00 2001 From: Tor Egge Date: Tue, 7 Feb 2023 10:28:26 +0100 Subject: Pass optional serial num to prepare reconfig. --- .../src/tests/proton/documentdb/configurer/configurer_test.cpp | 6 +++--- .../proton/documentdb/document_subdbs/document_subdbs_test.cpp | 2 +- searchcore/src/vespa/searchcore/proton/server/documentdb.cpp | 10 +++++----- searchcore/src/vespa/searchcore/proton/server/documentdb.h | 2 +- .../vespa/searchcore/proton/server/documentsubdbcollection.cpp | 8 ++++---- .../vespa/searchcore/proton/server/documentsubdbcollection.h | 3 ++- .../vespa/searchcore/proton/server/fast_access_doc_subdb.cpp | 4 ++-- .../src/vespa/searchcore/proton/server/fast_access_doc_subdb.h | 2 +- .../proton/server/fast_access_doc_subdb_configurer.cpp | 3 ++- .../proton/server/fast_access_doc_subdb_configurer.h | 2 +- searchcore/src/vespa/searchcore/proton/server/idocumentsubdb.h | 3 ++- .../proton/server/searchable_doc_subdb_configurer.cpp | 3 ++- .../searchcore/proton/server/searchable_doc_subdb_configurer.h | 2 +- .../src/vespa/searchcore/proton/server/searchabledocsubdb.cpp | 4 ++-- .../src/vespa/searchcore/proton/server/searchabledocsubdb.h | 2 +- .../src/vespa/searchcore/proton/server/storeonlydocsubdb.cpp | 3 ++- .../src/vespa/searchcore/proton/server/storeonlydocsubdb.h | 2 +- .../src/vespa/searchcore/proton/test/dummy_document_sub_db.h | 2 +- 18 files changed, 34 insertions(+), 29 deletions(-) diff --git a/searchcore/src/tests/proton/documentdb/configurer/configurer_test.cpp b/searchcore/src/tests/proton/documentdb/configurer/configurer_test.cpp index 2877005e2c1..d7ce042a4d3 100644 --- a/searchcore/src/tests/proton/documentdb/configurer/configurer_test.cpp +++ b/searchcore/src/tests/proton/documentdb/configurer/configurer_test.cpp @@ -246,7 +246,7 @@ Fixture::reconfigure(const DocumentDBConfig& new_config_snapshot, IDocumentDBReferenceResolver& resolver, SerialNum serial_num) { - auto prepared_reconfig = _configurer->prepare_reconfig(new_config_snapshot, old_config_snapshot, reconfig_params); + auto prepared_reconfig = _configurer->prepare_reconfig(new_config_snapshot, old_config_snapshot, reconfig_params, serial_num); _configurer->reconfigure(new_config_snapshot, old_config_snapshot, reconfig_params, resolver, *prepared_reconfig, serial_num); } @@ -258,7 +258,7 @@ Fixture::reconfigure(const DocumentDBConfig& new_config_snapshot, IDocumentDBReferenceResolver& resolver, SerialNum serial_num) { - auto prepared_reconfig = _configurer->prepare_reconfig(new_config_snapshot, old_config_snapshot, reconfig_params); + auto prepared_reconfig = _configurer->prepare_reconfig(new_config_snapshot, old_config_snapshot, reconfig_params, serial_num); return _configurer->reconfigure(new_config_snapshot, old_config_snapshot, std::move(attr_spec), reconfig_params, resolver, *prepared_reconfig, serial_num); } @@ -341,7 +341,7 @@ FastAccessFixture::reconfigure(const DocumentDBConfig& new_config_snapshot, SerialNum serial_num) { ReconfigParams reconfig_params{CCR()}; - auto prepared_reconfig = _configurer.prepare_reconfig(new_config_snapshot, old_config_snapshot, reconfig_params); + auto prepared_reconfig = _configurer.prepare_reconfig(new_config_snapshot, old_config_snapshot, reconfig_params, serial_num); return _configurer.reconfigure(new_config_snapshot, old_config_snapshot, std::move(attr_spec), *prepared_reconfig, serial_num); } diff --git a/searchcore/src/tests/proton/documentdb/document_subdbs/document_subdbs_test.cpp b/searchcore/src/tests/proton/documentdb/document_subdbs/document_subdbs_test.cpp index 307695c4f4b..f49c46d81e8 100644 --- a/searchcore/src/tests/proton/documentdb/document_subdbs/document_subdbs_test.cpp +++ b/searchcore/src/tests/proton/documentdb/document_subdbs/document_subdbs_test.cpp @@ -379,7 +379,7 @@ struct FixtureBase cmpResult.documentTypeRepoChanged = true; MyDocumentDBReferenceResolver resolver; ReconfigParams reconfig_params(cmpResult); - auto prepared_reconfig = _subDb.prepare_reconfig(*newCfg->_cfg, *_snapshot->_cfg, reconfig_params); + auto prepared_reconfig = _subDb.prepare_reconfig(*newCfg->_cfg, *_snapshot->_cfg, reconfig_params, serialNum); auto tasks = _subDb.applyConfig(*newCfg->_cfg, *_snapshot->_cfg, serialNum, reconfig_params, resolver, *prepared_reconfig); prepared_reconfig.reset(); diff --git a/searchcore/src/vespa/searchcore/proton/server/documentdb.cpp b/searchcore/src/vespa/searchcore/proton/server/documentdb.cpp index 110b0324dc3..356ddb6ddf3 100644 --- a/searchcore/src/vespa/searchcore/proton/server/documentdb.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/documentdb.cpp @@ -349,7 +349,7 @@ DocumentDB::initFinish(DocumentDBConfig::SP configSnapshot) } std::unique_ptr -DocumentDB::prepare_reconfig(const DocumentDBConfig& new_config_snapshot) +DocumentDB::prepare_reconfig(const DocumentDBConfig& new_config_snapshot, std::optional serial_num) { auto active_config_snapshot = getActiveConfig(); auto cmpres = active_config_snapshot->compare(new_config_snapshot); @@ -357,7 +357,7 @@ DocumentDB::prepare_reconfig(const DocumentDBConfig& new_config_snapshot) cmpres.importedFieldsChanged = true; } const ReconfigParams reconfig_params(cmpres); - return _subDBs.prepare_reconfig(new_config_snapshot, *active_config_snapshot, reconfig_params); + return _subDBs.prepare_reconfig(new_config_snapshot, *active_config_snapshot, reconfig_params, serial_num); } void @@ -796,7 +796,7 @@ DocumentDB::reconfigure(DocumentDBConfig::SP snapshot) assert(active_snapshot); assert(_state.getAllowReconfig()); snapshot = DocumentDBConfig::makeDelayedAttributeAspectConfig(snapshot, *active_snapshot); - auto prepared_reconfig = prepare_reconfig(*snapshot); + auto prepared_reconfig = prepare_reconfig(*snapshot, std::nullopt); masterExecute([this, snapshot, prepared_reconfig = std::move(prepared_reconfig)]() mutable { performReconfig(snapshot, std::move(prepared_reconfig)); }); // Wait for config to be applied, or for document db close std::unique_lock guard(_configMutex); @@ -835,7 +835,7 @@ DocumentDB::enterApplyLiveConfigState() (void) _state.enterApplyLiveConfigState(); } auto new_config_snapshot = _pendingConfigSnapshot.get(); - auto prepared_reconfig = prepare_reconfig(*new_config_snapshot); + auto prepared_reconfig = prepare_reconfig(*new_config_snapshot, std::nullopt); masterExecute([this, new_config_snapshot, prepared_reconfig = std::move(prepared_reconfig)]() mutable { performReconfig(std::move(new_config_snapshot), std::move(prepared_reconfig)); @@ -896,7 +896,7 @@ DocumentDB::replayConfig(search::SerialNum serialNum) configSnapshot = DocumentDBConfigScout::scout(configSnapshot, *_pendingConfigSnapshot.get()); // Ignore configs that are not relevant during replay of transaction log configSnapshot = DocumentDBConfig::makeReplayConfig(configSnapshot); - auto prepared_reconfig = prepare_reconfig(*configSnapshot); + auto prepared_reconfig = prepare_reconfig(*configSnapshot, serialNum); applyConfig(configSnapshot, serialNum, std::move(prepared_reconfig)); LOG(info, "DocumentDB(%s): Replayed config with serialNum=%" PRIu64, _docTypeName.toString().c_str(), serialNum); diff --git a/searchcore/src/vespa/searchcore/proton/server/documentdb.h b/searchcore/src/vespa/searchcore/proton/server/documentdb.h index 2b3e6ef4052..3e81a0505a0 100644 --- a/searchcore/src/vespa/searchcore/proton/server/documentdb.h +++ b/searchcore/src/vespa/searchcore/proton/server/documentdb.h @@ -382,7 +382,7 @@ public: bool getDelayedConfig() const { return _state.getDelayedConfig(); } void replayConfig(SerialNum serialNum) override; const DocTypeName & getDocTypeName() const { return _docTypeName; } - std::unique_ptr prepare_reconfig(const DocumentDBConfig& new_config_snapshot); + std::unique_ptr prepare_reconfig(const DocumentDBConfig& new_config_snapshot, std::optional serial_num); void reconfigure(DocumentDBConfigSP snapshot) override; int64_t getActiveGeneration() const; /* diff --git a/searchcore/src/vespa/searchcore/proton/server/documentsubdbcollection.cpp b/searchcore/src/vespa/searchcore/proton/server/documentsubdbcollection.cpp index 573683c21a9..2f0aecf9675 100644 --- a/searchcore/src/vespa/searchcore/proton/server/documentsubdbcollection.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/documentsubdbcollection.cpp @@ -251,10 +251,10 @@ DocumentSubDBCollection::pruneRemovedFields(SerialNum serialNum) } std::unique_ptr -DocumentSubDBCollection::prepare_reconfig(const DocumentDBConfig& new_config_snapshot, const DocumentDBConfig& old_config_snapshot, const ReconfigParams& reconfig_params) +DocumentSubDBCollection::prepare_reconfig(const DocumentDBConfig& new_config_snapshot, const DocumentDBConfig& old_config_snapshot, const ReconfigParams& reconfig_params, std::optional serial_num) { - auto ready_reconfig = getReadySubDB()->prepare_reconfig(new_config_snapshot, old_config_snapshot, reconfig_params); - auto not_ready_reconfig = getNotReadySubDB()->prepare_reconfig(new_config_snapshot, old_config_snapshot, reconfig_params); + auto ready_reconfig = getReadySubDB()->prepare_reconfig(new_config_snapshot, old_config_snapshot, reconfig_params, serial_num); + auto not_ready_reconfig = getNotReadySubDB()->prepare_reconfig(new_config_snapshot, old_config_snapshot, reconfig_params, serial_num); return std::make_unique(std::move(ready_reconfig), std::move(not_ready_reconfig)); } @@ -271,7 +271,7 @@ DocumentSubDBCollection::applyConfig(const DocumentDBConfig &newConfigSnapshot, _reprocessingRunner.addTasks(tasks); tasks = getNotReadySubDB()->applyConfig(newConfigSnapshot, oldConfigSnapshot, serialNum, params, resolver, prepared_reconfig.not_ready_reconfig()); _reprocessingRunner.addTasks(tasks); - auto removed_reconfig = getRemSubDB()->prepare_reconfig(newConfigSnapshot, oldConfigSnapshot, params); + auto removed_reconfig = getRemSubDB()->prepare_reconfig(newConfigSnapshot, oldConfigSnapshot, params, serialNum); tasks = getRemSubDB()->applyConfig(newConfigSnapshot, oldConfigSnapshot, serialNum, params, resolver, *removed_reconfig); removed_reconfig.reset(); _reprocessingRunner.addTasks(tasks); diff --git a/searchcore/src/vespa/searchcore/proton/server/documentsubdbcollection.h b/searchcore/src/vespa/searchcore/proton/server/documentsubdbcollection.h index 21f36c7ca3e..38b18f5406f 100644 --- a/searchcore/src/vespa/searchcore/proton/server/documentsubdbcollection.h +++ b/searchcore/src/vespa/searchcore/proton/server/documentsubdbcollection.h @@ -9,6 +9,7 @@ #include #include #include +#include namespace vespalib { class Clock; @@ -137,7 +138,7 @@ public: void pruneRemovedFields(SerialNum serialNum); - std::unique_ptr prepare_reconfig(const DocumentDBConfig& new_config_snapshot, const DocumentDBConfig& old_config_snapshot, const ReconfigParams& reconfig_params); + std::unique_ptr prepare_reconfig(const DocumentDBConfig& new_config_snapshot, const DocumentDBConfig& old_config_snapshot, const ReconfigParams& reconfig_params, std::optional serial_num); void applyConfig(const DocumentDBConfig &newConfigSnapshot, const DocumentDBConfig &oldConfigSnapshot, SerialNum serialNum, const ReconfigParams ¶ms, IDocumentDBReferenceResolver &resolver, const DocumentDBReconfig& prepared_reconfig); diff --git a/searchcore/src/vespa/searchcore/proton/server/fast_access_doc_subdb.cpp b/searchcore/src/vespa/searchcore/proton/server/fast_access_doc_subdb.cpp index 5a2e9447f9c..dfc463dc313 100644 --- a/searchcore/src/vespa/searchcore/proton/server/fast_access_doc_subdb.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/fast_access_doc_subdb.cpp @@ -244,9 +244,9 @@ FastAccessDocSubDB::initViews(const DocumentDBConfig &configSnapshot) } std::unique_ptr -FastAccessDocSubDB::prepare_reconfig(const DocumentDBConfig& new_config_snapshot, const DocumentDBConfig& old_config_snapshot, const ReconfigParams& reconfig_params) +FastAccessDocSubDB::prepare_reconfig(const DocumentDBConfig& new_config_snapshot, const DocumentDBConfig& old_config_snapshot, const ReconfigParams& reconfig_params, std::optional serial_num) { - return _configurer.prepare_reconfig(new_config_snapshot, old_config_snapshot, reconfig_params); + return _configurer.prepare_reconfig(new_config_snapshot, old_config_snapshot, reconfig_params, serial_num); } IReprocessingTask::List diff --git a/searchcore/src/vespa/searchcore/proton/server/fast_access_doc_subdb.h b/searchcore/src/vespa/searchcore/proton/server/fast_access_doc_subdb.h index cec2e8595cf..c211a49f999 100644 --- a/searchcore/src/vespa/searchcore/proton/server/fast_access_doc_subdb.h +++ b/searchcore/src/vespa/searchcore/proton/server/fast_access_doc_subdb.h @@ -111,7 +111,7 @@ public: void initViews(const DocumentDBConfig &configSnapshot) override; std::unique_ptr - prepare_reconfig(const DocumentDBConfig& new_config_snapshot, const DocumentDBConfig& old_config_snapshot, const ReconfigParams& reconfig_params) override; + prepare_reconfig(const DocumentDBConfig& new_config_snapshot, const DocumentDBConfig& old_config_snapshot, const ReconfigParams& reconfig_params, std::optional serial_num) override; IReprocessingTask::List applyConfig(const DocumentDBConfig &newConfigSnapshot, const DocumentDBConfig &oldConfigSnapshot, SerialNum serialNum, const ReconfigParams ¶ms, IDocumentDBReferenceResolver &resolver, const DocumentSubDBReconfig& prepared_reconfig) override; diff --git a/searchcore/src/vespa/searchcore/proton/server/fast_access_doc_subdb_configurer.cpp b/searchcore/src/vespa/searchcore/proton/server/fast_access_doc_subdb_configurer.cpp index a8211d246e1..a4108767d22 100644 --- a/searchcore/src/vespa/searchcore/proton/server/fast_access_doc_subdb_configurer.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/fast_access_doc_subdb_configurer.cpp @@ -46,11 +46,12 @@ FastAccessDocSubDBConfigurer::FastAccessDocSubDBConfigurer(FeedViewVarHolder &fe FastAccessDocSubDBConfigurer::~FastAccessDocSubDBConfigurer() = default; std::unique_ptr -FastAccessDocSubDBConfigurer::prepare_reconfig(const DocumentDBConfig& new_config_snapshot, const DocumentDBConfig& old_config_snapshot, const ReconfigParams& reconfig_params) +FastAccessDocSubDBConfigurer::prepare_reconfig(const DocumentDBConfig& new_config_snapshot, const DocumentDBConfig& old_config_snapshot, const ReconfigParams& reconfig_params, std::optional serial_num) { (void) new_config_snapshot; (void) old_config_snapshot; (void) reconfig_params; + (void) serial_num; return std::make_unique(std::shared_ptr()); } diff --git a/searchcore/src/vespa/searchcore/proton/server/fast_access_doc_subdb_configurer.h b/searchcore/src/vespa/searchcore/proton/server/fast_access_doc_subdb_configurer.h index 6d57a9cc3de..0bd71638128 100644 --- a/searchcore/src/vespa/searchcore/proton/server/fast_access_doc_subdb_configurer.h +++ b/searchcore/src/vespa/searchcore/proton/server/fast_access_doc_subdb_configurer.h @@ -33,7 +33,7 @@ public: const vespalib::string &subDbName); ~FastAccessDocSubDBConfigurer(); - std::unique_ptr prepare_reconfig(const DocumentDBConfig& new_config_snapshot, const DocumentDBConfig& old_config_snapshot, const ReconfigParams& reconfig_params); + std::unique_ptr prepare_reconfig(const DocumentDBConfig& new_config_snapshot, const DocumentDBConfig& old_config_snapshot, const ReconfigParams& reconfig_params, std::optional serial_num); IReprocessingInitializer::UP reconfigure(const DocumentDBConfig &newConfig, const DocumentDBConfig &oldConfig, diff --git a/searchcore/src/vespa/searchcore/proton/server/idocumentsubdb.h b/searchcore/src/vespa/searchcore/proton/server/idocumentsubdb.h index 99804fe253f..71f5b86cf87 100644 --- a/searchcore/src/vespa/searchcore/proton/server/idocumentsubdb.h +++ b/searchcore/src/vespa/searchcore/proton/server/idocumentsubdb.h @@ -7,6 +7,7 @@ #include #include #include +#include namespace search::index { class Schema; } @@ -80,7 +81,7 @@ public: virtual void initViews(const DocumentDBConfig &configSnapshot) = 0; virtual std::unique_ptr - prepare_reconfig(const DocumentDBConfig& new_config_snapshot, const DocumentDBConfig& old_config_snapshot, const ReconfigParams& reconfig_params) = 0; + prepare_reconfig(const DocumentDBConfig& new_config_snapshot, const DocumentDBConfig& old_config_snapshot, const ReconfigParams& reconfig_params, std::optional serial_num) = 0; virtual IReprocessingTask::List applyConfig(const DocumentDBConfig &newConfigSnapshot, const DocumentDBConfig &oldConfigSnapshot, SerialNum serialNum, const ReconfigParams ¶ms, IDocumentDBReferenceResolver &resolver, const DocumentSubDBReconfig& prepared_reconfig) = 0; diff --git a/searchcore/src/vespa/searchcore/proton/server/searchable_doc_subdb_configurer.cpp b/searchcore/src/vespa/searchcore/proton/server/searchable_doc_subdb_configurer.cpp index a934a445470..f9801e10981 100644 --- a/searchcore/src/vespa/searchcore/proton/server/searchable_doc_subdb_configurer.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/searchable_doc_subdb_configurer.cpp @@ -141,9 +141,10 @@ SearchableDocSubDBConfigurer::reconfigureIndexSearchable() } std::unique_ptr -SearchableDocSubDBConfigurer::prepare_reconfig(const DocumentDBConfig& new_config_snapshot, const DocumentDBConfig& old_config_snapshot, const ReconfigParams& reconfig_params) +SearchableDocSubDBConfigurer::prepare_reconfig(const DocumentDBConfig& new_config_snapshot, const DocumentDBConfig& old_config_snapshot, const ReconfigParams& reconfig_params, std::optional serial_num) { (void) old_config_snapshot; + (void) serial_num; auto old_matchers = _searchView.get()->getMatchers(); auto reconfig = std::make_unique(std::move(old_matchers)); if (reconfig_params.shouldMatchersChange()) { diff --git a/searchcore/src/vespa/searchcore/proton/server/searchable_doc_subdb_configurer.h b/searchcore/src/vespa/searchcore/proton/server/searchable_doc_subdb_configurer.h index b3ec169afeb..c397a41004f 100644 --- a/searchcore/src/vespa/searchcore/proton/server/searchable_doc_subdb_configurer.h +++ b/searchcore/src/vespa/searchcore/proton/server/searchable_doc_subdb_configurer.h @@ -78,7 +78,7 @@ public: void reconfigureIndexSearchable(); - std::unique_ptr prepare_reconfig(const DocumentDBConfig& new_config_snapshot, const DocumentDBConfig& old_config_snapshot, const ReconfigParams& reconfig_params); + std::unique_ptr prepare_reconfig(const DocumentDBConfig& new_config_snapshot, const DocumentDBConfig& old_config_snapshot, const ReconfigParams& reconfig_params, std::optional serial_num); void reconfigure(const DocumentDBConfig &newConfig, const DocumentDBConfig &oldConfig, diff --git a/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.cpp b/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.cpp index 89925e8a77d..7ee46d3f7a2 100644 --- a/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.cpp @@ -133,9 +133,9 @@ reconfigureMatchingMetrics(const RankProfilesConfig &cfg) } std::unique_ptr -SearchableDocSubDB::prepare_reconfig(const DocumentDBConfig& new_config_snapshot, const DocumentDBConfig& old_config_snapshot, const ReconfigParams& reconfig_params) +SearchableDocSubDB::prepare_reconfig(const DocumentDBConfig& new_config_snapshot, const DocumentDBConfig& old_config_snapshot, const ReconfigParams& reconfig_params, std::optional serial_num) { - return _configurer.prepare_reconfig(new_config_snapshot, old_config_snapshot, reconfig_params); + return _configurer.prepare_reconfig(new_config_snapshot, old_config_snapshot, reconfig_params, serial_num); } IReprocessingTask::List diff --git a/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.h b/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.h index 63100f7e6a9..075199ab891 100644 --- a/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.h +++ b/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.h @@ -101,7 +101,7 @@ public: void initViews(const DocumentDBConfig &configSnapshot) override; std::unique_ptr - prepare_reconfig(const DocumentDBConfig& new_config_snapshot, const DocumentDBConfig& old_config_snapshot, const ReconfigParams& reconfig_params) override; + prepare_reconfig(const DocumentDBConfig& new_config_snapshot, const DocumentDBConfig& old_config_snapshot, const ReconfigParams& reconfig_params, std::optional serial_num) override; IReprocessingTask::List applyConfig(const DocumentDBConfig &newConfigSnapshot, const DocumentDBConfig &oldConfigSnapshot, SerialNum serialNum, const ReconfigParams ¶ms, IDocumentDBReferenceResolver &resolver, const DocumentSubDBReconfig& prepared_reconfig) override; diff --git a/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.cpp b/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.cpp index 22aeeec4ef6..a099ac4f492 100644 --- a/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.cpp @@ -406,11 +406,12 @@ StoreOnlyDocSubDB::getSubDbName() const { } std::unique_ptr -StoreOnlyDocSubDB::prepare_reconfig(const DocumentDBConfig& new_config_snapshot, const DocumentDBConfig& old_config_snapshot, const ReconfigParams& reconfig_params) +StoreOnlyDocSubDB::prepare_reconfig(const DocumentDBConfig& new_config_snapshot, const DocumentDBConfig& old_config_snapshot, const ReconfigParams& reconfig_params, std::optional serial_num) { (void) new_config_snapshot; (void) old_config_snapshot; (void) reconfig_params; + (void) serial_num; return std::make_unique(std::shared_ptr()); } diff --git a/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.h b/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.h index f547ced67c7..574ba106339 100644 --- a/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.h +++ b/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.h @@ -201,7 +201,7 @@ public: void validateDocStore(FeedHandler & feedHandler, SerialNum serialNum) const override; std::unique_ptr - prepare_reconfig(const DocumentDBConfig& new_config_snapshot, const DocumentDBConfig& old_config_snapshot, const ReconfigParams& reconfig_params) override; + prepare_reconfig(const DocumentDBConfig& new_config_snapshot, const DocumentDBConfig& old_config_snapshot, const ReconfigParams& reconfig_params, std::optional serial_num) override; IReprocessingTask::List applyConfig(const DocumentDBConfig &newConfigSnapshot, const DocumentDBConfig &oldConfigSnapshot, SerialNum serialNum, const ReconfigParams ¶ms, IDocumentDBReferenceResolver &resolver, const DocumentSubDBReconfig &prepared_reconfig) override; diff --git a/searchcore/src/vespa/searchcore/proton/test/dummy_document_sub_db.h b/searchcore/src/vespa/searchcore/proton/test/dummy_document_sub_db.h index 85315158c3c..10e53625ace 100644 --- a/searchcore/src/vespa/searchcore/proton/test/dummy_document_sub_db.h +++ b/searchcore/src/vespa/searchcore/proton/test/dummy_document_sub_db.h @@ -52,7 +52,7 @@ struct DummyDocumentSubDb : public IDocumentSubDB } void setup(const DocumentSubDbInitializerResult &) override {} void initViews(const DocumentDBConfig &) override {} - std::unique_ptr prepare_reconfig(const DocumentDBConfig&, const DocumentDBConfig&, const ReconfigParams&) override { + std::unique_ptr prepare_reconfig(const DocumentDBConfig&, const DocumentDBConfig&, const ReconfigParams&, std::optional) override { return std::make_unique(std::shared_ptr()); } IReprocessingTask::List applyConfig(const DocumentDBConfig &, const DocumentDBConfig &, -- cgit v1.2.3 From 22998a859cdee573fc14fd9cb18572f9c7cd2498 Mon Sep 17 00:00:00 2001 From: Tor Egge Date: Tue, 7 Feb 2023 13:21:51 +0100 Subject: Call complete_prepare_reconfig() to adjust prepared reconfig when docid limit and serial number is known. --- .../attribute_manager/attribute_manager_test.cpp | 6 +++++- .../attribute/attribute_manager_initializer.cpp | 2 +- .../proton/attribute/attribute_manager_reconfig.cpp | 2 +- .../proton/attribute/attribute_manager_reconfig.h | 2 +- .../searchcore/proton/attribute/attributemanager.cpp | 14 +++++++------- .../searchcore/proton/attribute/attributemanager.h | 2 +- .../searchcore/proton/server/document_db_reconfig.cpp | 4 ++-- .../searchcore/proton/server/document_db_reconfig.h | 19 ++++++++++++------- .../proton/server/document_subdb_reconfig.cpp | 7 +++++++ .../proton/server/document_subdb_reconfig.h | 4 +++- .../src/vespa/searchcore/proton/server/documentdb.cpp | 3 ++- .../src/vespa/searchcore/proton/server/documentdb.h | 2 +- .../proton/server/documentsubdbcollection.cpp | 7 +++++++ .../proton/server/documentsubdbcollection.h | 1 + .../proton/server/fast_access_doc_subdb.cpp | 2 +- .../searchcore/proton/server/fast_access_doc_subdb.h | 2 +- .../server/fast_access_doc_subdb_configurer.cpp | 4 ++-- .../proton/server/fast_access_doc_subdb_configurer.h | 2 +- .../vespa/searchcore/proton/server/idocumentsubdb.h | 3 ++- .../proton/server/searchable_doc_subdb_configurer.cpp | 2 +- .../proton/server/searchable_doc_subdb_configurer.h | 2 +- .../searchcore/proton/server/searchabledocsubdb.cpp | 2 +- .../searchcore/proton/server/searchabledocsubdb.h | 2 +- .../searchcore/proton/server/storeonlydocsubdb.cpp | 10 ++++++++-- .../searchcore/proton/server/storeonlydocsubdb.h | 3 ++- .../searchcore/proton/test/dummy_document_sub_db.h | 5 +++-- 26 files changed, 75 insertions(+), 39 deletions(-) diff --git a/searchcore/src/tests/proton/attribute/attribute_manager/attribute_manager_test.cpp b/searchcore/src/tests/proton/attribute/attribute_manager/attribute_manager_test.cpp index 29639448023..88d0752461b 100644 --- a/searchcore/src/tests/proton/attribute/attribute_manager/attribute_manager_test.cpp +++ b/searchcore/src/tests/proton/attribute/attribute_manager/attribute_manager_test.cpp @@ -214,6 +214,8 @@ struct Fixture : public BaseFixture, public AttributeManagerFixture struct SequentialAttributeManager { SequentialAttributesInitializer initializer; + uint32_t docid_limit; + SerialNum serial_num; proton::AttributeManager mgr; SequentialAttributeManager(const AttributeManager &currMgr, AttrMgrSpec && newSpec); ~SequentialAttributeManager(); @@ -221,9 +223,11 @@ struct SequentialAttributeManager SequentialAttributeManager::SequentialAttributeManager(const AttributeManager &currMgr, AttrMgrSpec && newSpec) : initializer(newSpec.getDocIdLimit()), + docid_limit(newSpec.getDocIdLimit()), + serial_num(newSpec.getCurrentSerialNum().value_or(0)), mgr(currMgr, std::move(newSpec), initializer) { - mgr.addInitializedAttributes(initializer.getInitializedAttributes(), std::nullopt, std::nullopt); + mgr.addInitializedAttributes(initializer.getInitializedAttributes(), docid_limit, serial_num); } SequentialAttributeManager::~SequentialAttributeManager() = default; diff --git a/searchcore/src/vespa/searchcore/proton/attribute/attribute_manager_initializer.cpp b/searchcore/src/vespa/searchcore/proton/attribute/attribute_manager_initializer.cpp index c15a15e44e5..77cc1142f75 100644 --- a/searchcore/src/vespa/searchcore/proton/attribute/attribute_manager_initializer.cpp +++ b/searchcore/src/vespa/searchcore/proton/attribute/attribute_manager_initializer.cpp @@ -86,7 +86,7 @@ void AttributeManagerInitializerTask::run() { _attrMgr->addExtraAttribute(_documentMetaStore); - _attrMgr->addInitializedAttributes(_attributesResult.get(), std::nullopt, std::nullopt); + _attrMgr->addInitializedAttributes(_attributesResult.get(), 1, _configSerialNum); _attrMgr->pruneRemovedFields(_configSerialNum); _promise.set_value(); } diff --git a/searchcore/src/vespa/searchcore/proton/attribute/attribute_manager_reconfig.cpp b/searchcore/src/vespa/searchcore/proton/attribute/attribute_manager_reconfig.cpp index 2942256f534..06c03c80785 100644 --- a/searchcore/src/vespa/searchcore/proton/attribute/attribute_manager_reconfig.cpp +++ b/searchcore/src/vespa/searchcore/proton/attribute/attribute_manager_reconfig.cpp @@ -17,7 +17,7 @@ AttributeManagerReconfig::AttributeManagerReconfig(std::shared_ptr -AttributeManagerReconfig::create(std::optional docid_limit, std::optional serial_num) +AttributeManagerReconfig::create(uint32_t docid_limit, search::SerialNum serial_num) { assert(_mgr); _mgr->addInitializedAttributes(_initializer->getInitializedAttributes(), docid_limit, serial_num); diff --git a/searchcore/src/vespa/searchcore/proton/attribute/attribute_manager_reconfig.h b/searchcore/src/vespa/searchcore/proton/attribute/attribute_manager_reconfig.h index da8ae163fb5..9e4f8b71a7a 100644 --- a/searchcore/src/vespa/searchcore/proton/attribute/attribute_manager_reconfig.h +++ b/searchcore/src/vespa/searchcore/proton/attribute/attribute_manager_reconfig.h @@ -22,7 +22,7 @@ public: AttributeManagerReconfig(std::shared_ptr mgr, std::unique_ptr initializer); ~AttributeManagerReconfig(); - std::shared_ptr create(std::optional docid_limit, std::optional serial_num); + std::shared_ptr create(uint32_t docid_limit, search::SerialNum serial_num); }; } diff --git a/searchcore/src/vespa/searchcore/proton/attribute/attributemanager.cpp b/searchcore/src/vespa/searchcore/proton/attribute/attributemanager.cpp index e27fae65de3..636cb992b25 100644 --- a/searchcore/src/vespa/searchcore/proton/attribute/attributemanager.cpp +++ b/searchcore/src/vespa/searchcore/proton/attribute/attributemanager.cpp @@ -325,16 +325,14 @@ AttributeManager::addAttribute(AttributeSpec && spec, uint64_t serialNum) } void -AttributeManager::addInitializedAttributes(const std::vector &attributes, std::optional docid_limit, std::optional serial_num) +AttributeManager::addInitializedAttributes(const std::vector &attributes, uint32_t docid_limit, SerialNum serial_num) { for (const auto &result : attributes) { assert(result); auto attr = result.getAttribute(); - if (docid_limit.has_value()) { - AttributeManager::padAttribute(*attr, docid_limit.value()); - } - if (serial_num.has_value()) { - attr->setCreateSerialNum(serial_num.value()); + if (attr->getCreateSerialNum() == 0) { + AttributeManager::padAttribute(*attr, docid_limit); + attr->setCreateSerialNum(serial_num); } attr->setInterlock(_interlock); auto shrinker = allocShrinker(attr, _attributeFieldWriter, *_diskLayout); @@ -503,8 +501,10 @@ proton::IAttributeManager::SP AttributeManager::create(Spec&& spec) const { assert(spec.getCurrentSerialNum().has_value()); + auto docid_limit = spec.getDocIdLimit(); + auto serial_num = spec.getCurrentSerialNum().value(); auto prepared_result = prepare_create(std::move(spec)); - return prepared_result->create(std::nullopt, std::nullopt); + return prepared_result->create(docid_limit, serial_num); } std::vector diff --git a/searchcore/src/vespa/searchcore/proton/attribute/attributemanager.h b/searchcore/src/vespa/searchcore/proton/attribute/attributemanager.h index 35895e5422c..c8c5da7f4e4 100644 --- a/searchcore/src/vespa/searchcore/proton/attribute/attributemanager.h +++ b/searchcore/src/vespa/searchcore/proton/attribute/attributemanager.h @@ -123,7 +123,7 @@ public: AttributeVectorSP addAttribute(AttributeSpec && spec, uint64_t serialNum); - void addInitializedAttributes(const std::vector &attributes, std::optional docid_limit, std::optional serial_num); + void addInitializedAttributes(const std::vector &attributes, uint32_t docid_limit, SerialNum serial_num); void addExtraAttribute(const AttributeVectorSP &attribute); diff --git a/searchcore/src/vespa/searchcore/proton/server/document_db_reconfig.cpp b/searchcore/src/vespa/searchcore/proton/server/document_db_reconfig.cpp index 903c9d0a899..f0d028f924f 100644 --- a/searchcore/src/vespa/searchcore/proton/server/document_db_reconfig.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/document_db_reconfig.cpp @@ -5,8 +5,8 @@ namespace proton { -DocumentDBReconfig::DocumentDBReconfig(std::unique_ptr ready_reconfig_in, - std::unique_ptr not_ready_reconfig_in) +DocumentDBReconfig::DocumentDBReconfig(std::unique_ptr ready_reconfig_in, + std::unique_ptr not_ready_reconfig_in) : _ready_reconfig(std::move(ready_reconfig_in)), _not_ready_reconfig(std::move(not_ready_reconfig_in)) { diff --git a/searchcore/src/vespa/searchcore/proton/server/document_db_reconfig.h b/searchcore/src/vespa/searchcore/proton/server/document_db_reconfig.h index 21ea117f7e9..d35a2211397 100644 --- a/searchcore/src/vespa/searchcore/proton/server/document_db_reconfig.h +++ b/searchcore/src/vespa/searchcore/proton/server/document_db_reconfig.h @@ -10,26 +10,31 @@ class DocumentSubDBReconfig; /** * Class representing the result of the prepare step of a DocumentDB reconfig. * - * The reconfig is performed in two steps: + * The reconfig is performed in three steps: * Prepare: * Based on the config that is changed, new components are instantiated in each subdb. * This can be costly and is handled by helper threads from the shared executor pool. * + * Complete prepare: + * Docid limit and serial number are used to complete prepared reconfig. + * * Apply: * The new components are swapped with the old ones in the DocumentDB master write thread. */ class DocumentDBReconfig { private: - std::unique_ptr _ready_reconfig; - std::unique_ptr _not_ready_reconfig; + std::unique_ptr _ready_reconfig; + std::unique_ptr _not_ready_reconfig; public: - DocumentDBReconfig(std::unique_ptr ready_reconfig_in, - std::unique_ptr not_ready_reconfig_in); + DocumentDBReconfig(std::unique_ptr ready_reconfig_in, + std::unique_ptr not_ready_reconfig_in); ~DocumentDBReconfig(); - const DocumentSubDBReconfig& ready_reconfig() const { return *_ready_reconfig; } - const DocumentSubDBReconfig& not_ready_reconfig() const { return *_not_ready_reconfig; } + const DocumentSubDBReconfig& ready_reconfig() const noexcept { return *_ready_reconfig; } + DocumentSubDBReconfig& ready_reconfig() noexcept { return *_ready_reconfig; } + const DocumentSubDBReconfig& not_ready_reconfig() const noexcept { return *_not_ready_reconfig; } + DocumentSubDBReconfig& not_ready_reconfig() noexcept { return *_not_ready_reconfig; } }; } diff --git a/searchcore/src/vespa/searchcore/proton/server/document_subdb_reconfig.cpp b/searchcore/src/vespa/searchcore/proton/server/document_subdb_reconfig.cpp index 2fd222338e7..60514b91aab 100644 --- a/searchcore/src/vespa/searchcore/proton/server/document_subdb_reconfig.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/document_subdb_reconfig.cpp @@ -12,5 +12,12 @@ DocumentSubDBReconfig::DocumentSubDBReconfig(std::shared_ptr matchers_ DocumentSubDBReconfig::~DocumentSubDBReconfig() = default; +void +DocumentSubDBReconfig::complete(uint32_t docid_limit, search::SerialNum serial_num) +{ + (void) docid_limit; + (void) serial_num; +} + } diff --git a/searchcore/src/vespa/searchcore/proton/server/document_subdb_reconfig.h b/searchcore/src/vespa/searchcore/proton/server/document_subdb_reconfig.h index 89129a6b0d0..0554056100e 100644 --- a/searchcore/src/vespa/searchcore/proton/server/document_subdb_reconfig.h +++ b/searchcore/src/vespa/searchcore/proton/server/document_subdb_reconfig.h @@ -1,6 +1,7 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once +#include #include namespace proton { @@ -26,7 +27,8 @@ public: return _old_matchers != _new_matchers; } std::shared_ptr matchers() const { return _new_matchers; } + + void complete(uint32_t docid_limit, search::SerialNum serial_num); }; } - diff --git a/searchcore/src/vespa/searchcore/proton/server/documentdb.cpp b/searchcore/src/vespa/searchcore/proton/server/documentdb.cpp index 356ddb6ddf3..a217e3b719e 100644 --- a/searchcore/src/vespa/searchcore/proton/server/documentdb.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/documentdb.cpp @@ -423,7 +423,7 @@ DocumentDB::applySubDBConfig(const DocumentDBConfig &newConfigSnapshot, } void -DocumentDB::applyConfig(DocumentDBConfig::SP configSnapshot, SerialNum serialNum, std::unique_ptr prepared_reconfig) +DocumentDB::applyConfig(DocumentDBConfig::SP configSnapshot, SerialNum serialNum, std::unique_ptr prepared_reconfig) { // Always called by executor thread: // Called by performReconfig() by executor thread during normal @@ -472,6 +472,7 @@ DocumentDB::applyConfig(DocumentDBConfig::SP configSnapshot, SerialNum serialNum bool elidedConfigSave = equalReplayConfig && tlsReplayDone; forceCommitAndWait(*_feedView.get(), elidedConfigSave ? serialNum : serialNum - 1, std::move(commit_result)); } + _subDBs.complete_prepare_reconfig(*prepared_reconfig, serialNum); if (params.shouldMaintenanceControllerChange()) { _maintenanceController.killJobs(); } diff --git a/searchcore/src/vespa/searchcore/proton/server/documentdb.h b/searchcore/src/vespa/searchcore/proton/server/documentdb.h index 3e81a0505a0..6e611917a79 100644 --- a/searchcore/src/vespa/searchcore/proton/server/documentdb.h +++ b/searchcore/src/vespa/searchcore/proton/server/documentdb.h @@ -156,7 +156,7 @@ private: void applySubDBConfig(const DocumentDBConfig &newConfigSnapshot, SerialNum serialNum, const ReconfigParams ¶ms, const DocumentDBReconfig& prepared_reconfig); - void applyConfig(DocumentDBConfigSP configSnapshot, SerialNum serialNum, std::unique_ptr prepared_reconfig); + void applyConfig(DocumentDBConfigSP configSnapshot, SerialNum serialNum, std::unique_ptr prepared_reconfig); /** * Save initial config if we don't have any saved config snapshots. diff --git a/searchcore/src/vespa/searchcore/proton/server/documentsubdbcollection.cpp b/searchcore/src/vespa/searchcore/proton/server/documentsubdbcollection.cpp index 2f0aecf9675..73f90df11ab 100644 --- a/searchcore/src/vespa/searchcore/proton/server/documentsubdbcollection.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/documentsubdbcollection.cpp @@ -258,6 +258,13 @@ DocumentSubDBCollection::prepare_reconfig(const DocumentDBConfig& new_config_sna return std::make_unique(std::move(ready_reconfig), std::move(not_ready_reconfig)); } +void +DocumentSubDBCollection::complete_prepare_reconfig(DocumentDBReconfig& prepared_reconfig, SerialNum serial_num) +{ + getReadySubDB()->complete_prepare_reconfig(prepared_reconfig.ready_reconfig(), serial_num); + getNotReadySubDB()->complete_prepare_reconfig(prepared_reconfig.not_ready_reconfig(), serial_num); +} + void DocumentSubDBCollection::applyConfig(const DocumentDBConfig &newConfigSnapshot, const DocumentDBConfig &oldConfigSnapshot, diff --git a/searchcore/src/vespa/searchcore/proton/server/documentsubdbcollection.h b/searchcore/src/vespa/searchcore/proton/server/documentsubdbcollection.h index 38b18f5406f..a359ee8f0f3 100644 --- a/searchcore/src/vespa/searchcore/proton/server/documentsubdbcollection.h +++ b/searchcore/src/vespa/searchcore/proton/server/documentsubdbcollection.h @@ -139,6 +139,7 @@ public: void pruneRemovedFields(SerialNum serialNum); std::unique_ptr prepare_reconfig(const DocumentDBConfig& new_config_snapshot, const DocumentDBConfig& old_config_snapshot, const ReconfigParams& reconfig_params, std::optional serial_num); + void complete_prepare_reconfig(DocumentDBReconfig& prepared_reconfig, SerialNum serial_num); void applyConfig(const DocumentDBConfig &newConfigSnapshot, const DocumentDBConfig &oldConfigSnapshot, SerialNum serialNum, const ReconfigParams ¶ms, IDocumentDBReferenceResolver &resolver, const DocumentDBReconfig& prepared_reconfig); diff --git a/searchcore/src/vespa/searchcore/proton/server/fast_access_doc_subdb.cpp b/searchcore/src/vespa/searchcore/proton/server/fast_access_doc_subdb.cpp index dfc463dc313..eef605cea3c 100644 --- a/searchcore/src/vespa/searchcore/proton/server/fast_access_doc_subdb.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/fast_access_doc_subdb.cpp @@ -243,7 +243,7 @@ FastAccessDocSubDB::initViews(const DocumentDBConfig &configSnapshot) } } -std::unique_ptr +std::unique_ptr FastAccessDocSubDB::prepare_reconfig(const DocumentDBConfig& new_config_snapshot, const DocumentDBConfig& old_config_snapshot, const ReconfigParams& reconfig_params, std::optional serial_num) { return _configurer.prepare_reconfig(new_config_snapshot, old_config_snapshot, reconfig_params, serial_num); diff --git a/searchcore/src/vespa/searchcore/proton/server/fast_access_doc_subdb.h b/searchcore/src/vespa/searchcore/proton/server/fast_access_doc_subdb.h index c211a49f999..e4c140e43e6 100644 --- a/searchcore/src/vespa/searchcore/proton/server/fast_access_doc_subdb.h +++ b/searchcore/src/vespa/searchcore/proton/server/fast_access_doc_subdb.h @@ -110,7 +110,7 @@ public: void setup(const DocumentSubDbInitializerResult &initResult) override; void initViews(const DocumentDBConfig &configSnapshot) override; - std::unique_ptr + std::unique_ptr prepare_reconfig(const DocumentDBConfig& new_config_snapshot, const DocumentDBConfig& old_config_snapshot, const ReconfigParams& reconfig_params, std::optional serial_num) override; IReprocessingTask::List applyConfig(const DocumentDBConfig &newConfigSnapshot, const DocumentDBConfig &oldConfigSnapshot, diff --git a/searchcore/src/vespa/searchcore/proton/server/fast_access_doc_subdb_configurer.cpp b/searchcore/src/vespa/searchcore/proton/server/fast_access_doc_subdb_configurer.cpp index a4108767d22..0a88b591f9f 100644 --- a/searchcore/src/vespa/searchcore/proton/server/fast_access_doc_subdb_configurer.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/fast_access_doc_subdb_configurer.cpp @@ -45,14 +45,14 @@ FastAccessDocSubDBConfigurer::FastAccessDocSubDBConfigurer(FeedViewVarHolder &fe FastAccessDocSubDBConfigurer::~FastAccessDocSubDBConfigurer() = default; -std::unique_ptr +std::unique_ptr FastAccessDocSubDBConfigurer::prepare_reconfig(const DocumentDBConfig& new_config_snapshot, const DocumentDBConfig& old_config_snapshot, const ReconfigParams& reconfig_params, std::optional serial_num) { (void) new_config_snapshot; (void) old_config_snapshot; (void) reconfig_params; (void) serial_num; - return std::make_unique(std::shared_ptr()); + return std::make_unique(std::shared_ptr()); } IReprocessingInitializer::UP diff --git a/searchcore/src/vespa/searchcore/proton/server/fast_access_doc_subdb_configurer.h b/searchcore/src/vespa/searchcore/proton/server/fast_access_doc_subdb_configurer.h index 0bd71638128..7a50aa35c81 100644 --- a/searchcore/src/vespa/searchcore/proton/server/fast_access_doc_subdb_configurer.h +++ b/searchcore/src/vespa/searchcore/proton/server/fast_access_doc_subdb_configurer.h @@ -33,7 +33,7 @@ public: const vespalib::string &subDbName); ~FastAccessDocSubDBConfigurer(); - std::unique_ptr prepare_reconfig(const DocumentDBConfig& new_config_snapshot, const DocumentDBConfig& old_config_snapshot, const ReconfigParams& reconfig_params, std::optional serial_num); + std::unique_ptr prepare_reconfig(const DocumentDBConfig& new_config_snapshot, const DocumentDBConfig& old_config_snapshot, const ReconfigParams& reconfig_params, std::optional serial_num); IReprocessingInitializer::UP reconfigure(const DocumentDBConfig &newConfig, const DocumentDBConfig &oldConfig, diff --git a/searchcore/src/vespa/searchcore/proton/server/idocumentsubdb.h b/searchcore/src/vespa/searchcore/proton/server/idocumentsubdb.h index 71f5b86cf87..bdf3d7c7102 100644 --- a/searchcore/src/vespa/searchcore/proton/server/idocumentsubdb.h +++ b/searchcore/src/vespa/searchcore/proton/server/idocumentsubdb.h @@ -80,8 +80,9 @@ public: virtual void setup(const DocumentSubDbInitializerResult &initResult) = 0; virtual void initViews(const DocumentDBConfig &configSnapshot) = 0; - virtual std::unique_ptr + virtual std::unique_ptr prepare_reconfig(const DocumentDBConfig& new_config_snapshot, const DocumentDBConfig& old_config_snapshot, const ReconfigParams& reconfig_params, std::optional serial_num) = 0; + virtual void complete_prepare_reconfig(DocumentSubDBReconfig& prepared_reconfig, SerialNum serial_num) = 0; virtual IReprocessingTask::List applyConfig(const DocumentDBConfig &newConfigSnapshot, const DocumentDBConfig &oldConfigSnapshot, SerialNum serialNum, const ReconfigParams ¶ms, IDocumentDBReferenceResolver &resolver, const DocumentSubDBReconfig& prepared_reconfig) = 0; diff --git a/searchcore/src/vespa/searchcore/proton/server/searchable_doc_subdb_configurer.cpp b/searchcore/src/vespa/searchcore/proton/server/searchable_doc_subdb_configurer.cpp index f9801e10981..fa4340f7659 100644 --- a/searchcore/src/vespa/searchcore/proton/server/searchable_doc_subdb_configurer.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/searchable_doc_subdb_configurer.cpp @@ -140,7 +140,7 @@ SearchableDocSubDBConfigurer::reconfigureIndexSearchable() reconfigureMatchView(indexManager->getSearchable()); } -std::unique_ptr +std::unique_ptr SearchableDocSubDBConfigurer::prepare_reconfig(const DocumentDBConfig& new_config_snapshot, const DocumentDBConfig& old_config_snapshot, const ReconfigParams& reconfig_params, std::optional serial_num) { (void) old_config_snapshot; diff --git a/searchcore/src/vespa/searchcore/proton/server/searchable_doc_subdb_configurer.h b/searchcore/src/vespa/searchcore/proton/server/searchable_doc_subdb_configurer.h index c397a41004f..e6b0ebda7c1 100644 --- a/searchcore/src/vespa/searchcore/proton/server/searchable_doc_subdb_configurer.h +++ b/searchcore/src/vespa/searchcore/proton/server/searchable_doc_subdb_configurer.h @@ -78,7 +78,7 @@ public: void reconfigureIndexSearchable(); - std::unique_ptr prepare_reconfig(const DocumentDBConfig& new_config_snapshot, const DocumentDBConfig& old_config_snapshot, const ReconfigParams& reconfig_params, std::optional serial_num); + std::unique_ptr prepare_reconfig(const DocumentDBConfig& new_config_snapshot, const DocumentDBConfig& old_config_snapshot, const ReconfigParams& reconfig_params, std::optional serial_num); void reconfigure(const DocumentDBConfig &newConfig, const DocumentDBConfig &oldConfig, diff --git a/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.cpp b/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.cpp index 7ee46d3f7a2..187be079d03 100644 --- a/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.cpp @@ -132,7 +132,7 @@ reconfigureMatchingMetrics(const RankProfilesConfig &cfg) } } -std::unique_ptr +std::unique_ptr SearchableDocSubDB::prepare_reconfig(const DocumentDBConfig& new_config_snapshot, const DocumentDBConfig& old_config_snapshot, const ReconfigParams& reconfig_params, std::optional serial_num) { return _configurer.prepare_reconfig(new_config_snapshot, old_config_snapshot, reconfig_params, serial_num); diff --git a/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.h b/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.h index 075199ab891..522ccd69b2a 100644 --- a/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.h +++ b/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.h @@ -100,7 +100,7 @@ public: void setup(const DocumentSubDbInitializerResult &initResult) override; void initViews(const DocumentDBConfig &configSnapshot) override; - std::unique_ptr + std::unique_ptr prepare_reconfig(const DocumentDBConfig& new_config_snapshot, const DocumentDBConfig& old_config_snapshot, const ReconfigParams& reconfig_params, std::optional serial_num) override; IReprocessingTask::List applyConfig(const DocumentDBConfig &newConfigSnapshot, const DocumentDBConfig &oldConfigSnapshot, diff --git a/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.cpp b/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.cpp index a099ac4f492..e3cf394c143 100644 --- a/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.cpp @@ -405,14 +405,20 @@ StoreOnlyDocSubDB::getSubDbName() const { return vespalib::make_string("%s.%s", _owner.getName().c_str(), _subName.c_str()); } -std::unique_ptr +std::unique_ptr StoreOnlyDocSubDB::prepare_reconfig(const DocumentDBConfig& new_config_snapshot, const DocumentDBConfig& old_config_snapshot, const ReconfigParams& reconfig_params, std::optional serial_num) { (void) new_config_snapshot; (void) old_config_snapshot; (void) reconfig_params; (void) serial_num; - return std::make_unique(std::shared_ptr()); + return std::make_unique(std::shared_ptr()); +} + +void +StoreOnlyDocSubDB::complete_prepare_reconfig(DocumentSubDBReconfig& prepared_reconfig, SerialNum serial_num) +{ + prepared_reconfig.complete(_dms->getCommittedDocIdLimit(), serial_num); } IReprocessingTask::List diff --git a/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.h b/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.h index 574ba106339..0abb06a76aa 100644 --- a/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.h +++ b/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.h @@ -200,8 +200,9 @@ public: void validateDocStore(FeedHandler & feedHandler, SerialNum serialNum) const override; - std::unique_ptr + std::unique_ptr prepare_reconfig(const DocumentDBConfig& new_config_snapshot, const DocumentDBConfig& old_config_snapshot, const ReconfigParams& reconfig_params, std::optional serial_num) override; + void complete_prepare_reconfig(DocumentSubDBReconfig& prepared_reconfig, SerialNum serial_num) override; IReprocessingTask::List applyConfig(const DocumentDBConfig &newConfigSnapshot, const DocumentDBConfig &oldConfigSnapshot, SerialNum serialNum, const ReconfigParams ¶ms, IDocumentDBReferenceResolver &resolver, const DocumentSubDBReconfig &prepared_reconfig) override; diff --git a/searchcore/src/vespa/searchcore/proton/test/dummy_document_sub_db.h b/searchcore/src/vespa/searchcore/proton/test/dummy_document_sub_db.h index 10e53625ace..5ab0109578c 100644 --- a/searchcore/src/vespa/searchcore/proton/test/dummy_document_sub_db.h +++ b/searchcore/src/vespa/searchcore/proton/test/dummy_document_sub_db.h @@ -52,9 +52,10 @@ struct DummyDocumentSubDb : public IDocumentSubDB } void setup(const DocumentSubDbInitializerResult &) override {} void initViews(const DocumentDBConfig &) override {} - std::unique_ptr prepare_reconfig(const DocumentDBConfig&, const DocumentDBConfig&, const ReconfigParams&, std::optional) override { - return std::make_unique(std::shared_ptr()); + std::unique_ptr prepare_reconfig(const DocumentDBConfig&, const DocumentDBConfig&, const ReconfigParams&, std::optional) override { + return std::make_unique(std::shared_ptr()); } + void complete_prepare_reconfig(DocumentSubDBReconfig&, SerialNum) override { } IReprocessingTask::List applyConfig(const DocumentDBConfig &, const DocumentDBConfig &, SerialNum, const ReconfigParams &, IDocumentDBReferenceResolver &, const DocumentSubDBReconfig&) override { -- cgit v1.2.3 From 1fb56a093caf4369189e0d00ff3e406d674ec420 Mon Sep 17 00:00:00 2001 From: Tor Egge Date: Tue, 7 Feb 2023 14:40:35 +0100 Subject: Add comments describing when attribute vector create serial number is set. --- .../src/vespa/searchcore/proton/attribute/attributemanager.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/searchcore/src/vespa/searchcore/proton/attribute/attributemanager.cpp b/searchcore/src/vespa/searchcore/proton/attribute/attributemanager.cpp index 636cb992b25..dd6cc1bdb85 100644 --- a/searchcore/src/vespa/searchcore/proton/attribute/attributemanager.cpp +++ b/searchcore/src/vespa/searchcore/proton/attribute/attributemanager.cpp @@ -327,10 +327,20 @@ AttributeManager::addAttribute(AttributeSpec && spec, uint64_t serialNum) void AttributeManager::addInitializedAttributes(const std::vector &attributes, uint32_t docid_limit, SerialNum serial_num) { + /* + * Called (indirectly) by + * DocumentSubDBCollection::complete_prepare_reconfig to complete + * setup of new attribute manager. + */ for (const auto &result : attributes) { assert(result); auto attr = result.getAttribute(); if (attr->getCreateSerialNum() == 0) { + /* + * The attribute vector is empty (not loaded from disk) + * and has been added as part of live reconfig. Make it + * ready for use by setting size and create serial num. + */ AttributeManager::padAttribute(*attr, docid_limit); attr->setCreateSerialNum(serial_num); } -- cgit v1.2.3