diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2021-11-16 17:40:04 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-16 17:40:04 +0100 |
commit | d084da4f352cdfb6d42f2be1e4693065b2e532b2 (patch) | |
tree | 6b92ccc72f6db961c0b6834489f5cd9e7defca59 | |
parent | d15f16f7aec9a7478a67331b25d2557ba0a3ea53 (diff) | |
parent | ae3fd54bd8c4702c528e7f020ad8d12611e49404 (diff) |
Merge pull request #20049 from vespa-engine/toregge/use-gate-callback-to-signal-completion-5
Use GateCallback to signal completion of force commit.
-rw-r--r-- | searchcore/src/vespa/searchcore/proton/server/documentdb.cpp | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/searchcore/src/vespa/searchcore/proton/server/documentdb.cpp b/searchcore/src/vespa/searchcore/proton/server/documentdb.cpp index 109571296ec..3f2fb6c4634 100644 --- a/searchcore/src/vespa/searchcore/proton/server/documentdb.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/documentdb.cpp @@ -62,6 +62,8 @@ using storage::spi::Timestamp; using search::common::FileHeaderContext; using proton::initializer::InitializerTask; using proton::initializer::TaskRunner; +using vespalib::GateCallback; +using vespalib::IDestructorCallback; using vespalib::makeLambdaTask; using searchcorespi::IFlushTarget; @@ -375,9 +377,13 @@ void DocumentDB::enterOnlineState() { // Called by executor thread - // Ensure that all replayed operations are committed to memory structures - _feedView.get()->forceCommit(CommitParam(_feedHandler->getSerialNum())); - _writeService.sync_all_executors(); + assert(_writeService.master().isCurrentThread()); + { + vespalib::Gate gate; + // Ensure that all replayed operations are committed to memory structures + _feedView.get()->forceCommit(CommitParam(_feedHandler->getSerialNum()), std::make_shared<GateCallback>(gate)); + gate.await(); + } (void) _state.enterOnlineState(); // Consider delayed pruning of transaction log and config history @@ -463,10 +469,11 @@ DocumentDB::applyConfig(DocumentDBConfig::SP configSnapshot, SerialNum serialNum } { bool elidedConfigSave = equalReplayConfig && tlsReplayDone; + vespalib::Gate gate; // Flush changes to attributes and memory index, cf. visibilityDelay _feedView.get()->forceCommit(CommitParam(elidedConfigSave ? serialNum : serialNum - 1), - std::make_shared<vespalib::KeepAlive<FeedHandler::CommitResult>>(std::move(commit_result))); - _writeService.sync_all_executors(); + std::make_shared<vespalib::KeepAlive<std::pair<FeedHandler::CommitResult, std::shared_ptr<IDestructorCallback>>>>(std::make_pair(std::move(commit_result), std::make_shared<GateCallback>(gate)))); + gate.await(); } if (params.shouldMaintenanceControllerChange()) { _maintenanceController.killJobs(); |