diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2020-07-07 11:55:06 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2020-07-07 11:55:06 +0000 |
commit | 846f628a129ce3e783cdfbfa833d123fc7693ab6 (patch) | |
tree | 3a65d136672b45eecf594b80982057326b134f36 | |
parent | 4f5979902977694ca025d2535192d790e8d3be3a (diff) |
Async handling of gid/lid changes.
17 files changed, 108 insertions, 102 deletions
diff --git a/searchcore/src/tests/proton/documentdb/feedview/feedview_test.cpp b/searchcore/src/tests/proton/documentdb/feedview/feedview_test.cpp index ddf45d6a509..38d5b0d35b1 100644 --- a/searchcore/src/tests/proton/documentdb/feedview/feedview_test.cpp +++ b/searchcore/src/tests/proton/documentdb/feedview/feedview_test.cpp @@ -185,21 +185,21 @@ public: { } - virtual void notifyPutDone(document::GlobalId gid, uint32_t lid, SerialNum) override { + void notifyPutDone(Context, document::GlobalId gid, uint32_t lid, SerialNum) override { _changeGid = gid; _changeLid = lid; _gidToLid[gid] = lid; ++_changes; } - virtual void notifyRemove(document::GlobalId gid, SerialNum) override { + void notifyRemove(Context, document::GlobalId gid, SerialNum) override { _changeGid = gid; _changeLid = 0; _gidToLid[gid] = 0; ++_changes; } - virtual void notifyRemoveDone(document::GlobalId, SerialNum) override { + void notifyRemoveDone(document::GlobalId, SerialNum) override { } void assertChanges(document::GlobalId expGid, uint32_t expLid, uint32_t expChanges) { diff --git a/searchcore/src/tests/proton/reference/gid_to_lid_change_handler/gid_to_lid_change_handler_test.cpp b/searchcore/src/tests/proton/reference/gid_to_lid_change_handler/gid_to_lid_change_handler_test.cpp index 1201bc4720b..0c69fbaed55 100644 --- a/searchcore/src/tests/proton/reference/gid_to_lid_change_handler/gid_to_lid_change_handler_test.cpp +++ b/searchcore/src/tests/proton/reference/gid_to_lid_change_handler/gid_to_lid_change_handler_test.cpp @@ -7,6 +7,7 @@ #include <vespa/vespalib/util/lambdatask.h> #include <vespa/searchcore/proton/reference/i_gid_to_lid_change_listener.h> #include <vespa/searchcore/proton/reference/gid_to_lid_change_handler.h> +#include <vespa/searchlib/common/gatecallback.h> #include <map> #include <vespa/log/log.h> LOG_SETUP("gid_to_lid_change_handler_test"); @@ -100,12 +101,12 @@ public: { _stats.markCreatedListener(); } - virtual ~MyListener() { _stats.markDestroyedListener(); } - virtual void notifyPutDone(GlobalId, uint32_t) override { _stats.notifyPutDone(); } - virtual void notifyRemove(GlobalId) override { _stats.notifyRemove(); } - virtual void notifyRegistered() override { _stats.markRegisteredListener(); } - virtual const vespalib::string &getName() const override { return _name; } - virtual const vespalib::string &getDocTypeName() const override { return _docTypeName; } + ~MyListener() override { _stats.markDestroyedListener(); } + void notifyPutDone(Context, GlobalId, uint32_t) override { _stats.notifyPutDone(); } + void notifyRemove(Context, GlobalId) override { _stats.notifyRemove(); } + void notifyRegistered() override { _stats.markRegisteredListener(); } + const vespalib::string &getName() const override { return _name; } + const vespalib::string &getDocTypeName() const override { return _docTypeName; } }; struct Fixture @@ -139,11 +140,15 @@ struct Fixture } void notifyPutDone(GlobalId gid, uint32_t lid, SerialNum serialNum) { - _handler->notifyPutDone(gid, lid, serialNum); + vespalib::Gate gate; + _handler->notifyPutDone(std::make_shared<search::GateCallback>(gate), gid, lid, serialNum); + gate.await(); } void notifyRemove(GlobalId gid, SerialNum serialNum) { - _handler->notifyRemove(gid, serialNum); + vespalib::Gate gate; + _handler->notifyRemove(std::make_shared<search::GateCallback>(gate), gid, serialNum); + gate.await(); } void notifyRemoveDone(GlobalId gid, SerialNum serialNum) { diff --git a/searchcore/src/tests/proton/reference/gid_to_lid_change_listener/gid_to_lid_change_listener_test.cpp b/searchcore/src/tests/proton/reference/gid_to_lid_change_listener/gid_to_lid_change_listener_test.cpp index 2fb439ea530..e9363d66433 100644 --- a/searchcore/src/tests/proton/reference/gid_to_lid_change_listener/gid_to_lid_change_listener_test.cpp +++ b/searchcore/src/tests/proton/reference/gid_to_lid_change_listener/gid_to_lid_change_listener_test.cpp @@ -7,6 +7,7 @@ #include <vespa/searchcore/proton/reference/gid_to_lid_change_listener.h> #include <vespa/searchlib/common/i_gid_to_lid_mapper_factory.h> #include <vespa/searchlib/common/i_gid_to_lid_mapper.h> +#include <vespa/searchlib/common/gatecallback.h> #include <vespa/searchlib/test/mock_gid_to_lid_mapping.h> #include <map> #include <vespa/log/log.h> @@ -95,7 +96,9 @@ struct Fixture } void notifyPutDone(const GlobalId &gid, uint32_t referencedDoc) { - _listener->notifyPutDone(gid, referencedDoc); + vespalib::Gate gate; + _listener->notifyPutDone(std::make_shared<search::GateCallback>(gate), gid, referencedDoc); + gate.await(); } void notifyListenerRegistered() { diff --git a/searchcore/src/tests/proton/reference/gid_to_lid_change_registrator/gid_to_lid_change_registrator_test.cpp b/searchcore/src/tests/proton/reference/gid_to_lid_change_registrator/gid_to_lid_change_registrator_test.cpp index d240c437ef2..6fcc57ce398 100644 --- a/searchcore/src/tests/proton/reference/gid_to_lid_change_registrator/gid_to_lid_change_registrator_test.cpp +++ b/searchcore/src/tests/proton/reference/gid_to_lid_change_registrator/gid_to_lid_change_registrator_test.cpp @@ -23,12 +23,12 @@ public: _name(name) { } - virtual ~MyListener() { } - virtual void notifyPutDone(document::GlobalId, uint32_t) override { } - virtual void notifyRemove(document::GlobalId) override { } - virtual void notifyRegistered() override { } - virtual const vespalib::string &getName() const override { return _name; } - virtual const vespalib::string &getDocTypeName() const override { return _docTypeName; } + ~MyListener() override { } + void notifyPutDone(Context, document::GlobalId, uint32_t) override { } + void notifyRemove(Context, document::GlobalId) override { } + void notifyRegistered() override { } + const vespalib::string &getName() const override { return _name; } + const vespalib::string &getDocTypeName() const override { return _docTypeName; } }; @@ -46,9 +46,7 @@ struct Fixture { } - ~Fixture() - { - } + ~Fixture() { } std::unique_ptr<GidToLidChangeRegistrator> getRegistrator(const vespalib::string &docTypeName) { diff --git a/searchcore/src/vespa/searchcore/proton/reference/dummy_gid_to_lid_change_handler.cpp b/searchcore/src/vespa/searchcore/proton/reference/dummy_gid_to_lid_change_handler.cpp index 8f70d697b9a..42b2facc138 100644 --- a/searchcore/src/vespa/searchcore/proton/reference/dummy_gid_to_lid_change_handler.cpp +++ b/searchcore/src/vespa/searchcore/proton/reference/dummy_gid_to_lid_change_handler.cpp @@ -4,23 +4,17 @@ namespace proton { -DummyGidToLidChangeHandler::DummyGidToLidChangeHandler() - : IGidToLidChangeHandler() +DummyGidToLidChangeHandler::DummyGidToLidChangeHandler() = default; -{ -} - -DummyGidToLidChangeHandler::~DummyGidToLidChangeHandler() -{ -} +DummyGidToLidChangeHandler::~DummyGidToLidChangeHandler() = default; void -DummyGidToLidChangeHandler::notifyPutDone(GlobalId, uint32_t, SerialNum) +DummyGidToLidChangeHandler::notifyPutDone(Context , GlobalId, uint32_t, SerialNum) { } void -DummyGidToLidChangeHandler::notifyRemove(GlobalId, SerialNum) +DummyGidToLidChangeHandler::notifyRemove(Context , GlobalId, SerialNum) { } diff --git a/searchcore/src/vespa/searchcore/proton/reference/dummy_gid_to_lid_change_handler.h b/searchcore/src/vespa/searchcore/proton/reference/dummy_gid_to_lid_change_handler.h index 4e5a0389add..3527980cc7f 100644 --- a/searchcore/src/vespa/searchcore/proton/reference/dummy_gid_to_lid_change_handler.h +++ b/searchcore/src/vespa/searchcore/proton/reference/dummy_gid_to_lid_change_handler.h @@ -20,14 +20,13 @@ class DummyGidToLidChangeHandler : public IGidToLidChangeHandler { public: DummyGidToLidChangeHandler(); - virtual ~DummyGidToLidChangeHandler(); + ~DummyGidToLidChangeHandler() override; - virtual void notifyPutDone(GlobalId gid, uint32_t lid, SerialNum serialNum) override; - virtual void notifyRemove(GlobalId gid, SerialNum serialNum) override; - virtual void notifyRemoveDone(GlobalId gid, SerialNum serialNum) override; - virtual void addListener(std::unique_ptr<IGidToLidChangeListener> listener) override; - virtual void removeListeners(const vespalib::string &docTypeName, - const std::set<vespalib::string> &keepNames) override; + void notifyPutDone(Context context, GlobalId gid, uint32_t lid, SerialNum serialNum) override; + void notifyRemove(Context context, GlobalId gid, SerialNum serialNum) override; + void notifyRemoveDone(GlobalId gid, SerialNum serialNum) override; + void addListener(std::unique_ptr<IGidToLidChangeListener> listener) override; + void removeListeners(const vespalib::string &docTypeName, const std::set<vespalib::string> &keepNames) override; }; } // namespace proton diff --git a/searchcore/src/vespa/searchcore/proton/reference/gid_to_lid_change_handler.cpp b/searchcore/src/vespa/searchcore/proton/reference/gid_to_lid_change_handler.cpp index abaf37f5084..58873060c6c 100644 --- a/searchcore/src/vespa/searchcore/proton/reference/gid_to_lid_change_handler.cpp +++ b/searchcore/src/vespa/searchcore/proton/reference/gid_to_lid_change_handler.cpp @@ -2,10 +2,9 @@ #include "gid_to_lid_change_handler.h" #include "i_gid_to_lid_change_listener.h" -#include <vespa/searchcorespi/index/i_thread_service.h> -#include <vespa/vespalib/stllike/hash_map.hpp> #include <vespa/vespalib/util/lambdatask.h> #include <cassert> +#include <vespa/vespalib/stllike/hash_map.hpp> using vespalib::makeLambdaTask; @@ -28,23 +27,23 @@ GidToLidChangeHandler::~GidToLidChangeHandler() } void -GidToLidChangeHandler::notifyPutDone(GlobalId gid, uint32_t lid) +GidToLidChangeHandler::notifyPutDone(Context context, GlobalId gid, uint32_t lid) { for (const auto &listener : _listeners) { - listener->notifyPutDone(gid, lid); + listener->notifyPutDone(context, gid, lid); } } void -GidToLidChangeHandler::notifyRemove(GlobalId gid) +GidToLidChangeHandler::notifyRemove(Context context, GlobalId gid) { for (const auto &listener : _listeners) { - listener->notifyRemove(gid); + listener->notifyRemove(context, gid); } } void -GidToLidChangeHandler::notifyPutDone(GlobalId gid, uint32_t lid, SerialNum serialNum) +GidToLidChangeHandler::notifyPutDone(Context context, GlobalId gid, uint32_t lid, SerialNum serialNum) { lock_guard guard(_lock); auto itr = _pendingRemove.find(gid); @@ -60,11 +59,11 @@ GidToLidChangeHandler::notifyPutDone(GlobalId gid, uint32_t lid, SerialNum seria } entry.putSerialNum = serialNum; } - notifyPutDone(gid, lid); + notifyPutDone(std::move(context), gid, lid); } void -GidToLidChangeHandler::notifyRemove(GlobalId gid, SerialNum serialNum) +GidToLidChangeHandler::notifyRemove(Context context, GlobalId gid, SerialNum serialNum) { lock_guard guard(_lock); auto insRes = _pendingRemove.insert(std::make_pair(gid, PendingRemoveEntry(serialNum))); @@ -73,12 +72,12 @@ GidToLidChangeHandler::notifyRemove(GlobalId gid, SerialNum serialNum) assert(entry.removeSerialNum < serialNum); assert(entry.putSerialNum < serialNum); if (entry.removeSerialNum < entry.putSerialNum) { - notifyRemove(gid); + notifyRemove(std::move(context), gid); } entry.removeSerialNum = serialNum; ++entry.refCount; } else { - notifyRemove(gid); + notifyRemove(std::move(context), gid); } } diff --git a/searchcore/src/vespa/searchcore/proton/reference/gid_to_lid_change_handler.h b/searchcore/src/vespa/searchcore/proton/reference/gid_to_lid_change_handler.h index c72e9a07078..61ad2ad31ae 100644 --- a/searchcore/src/vespa/searchcore/proton/reference/gid_to_lid_change_handler.h +++ b/searchcore/src/vespa/searchcore/proton/reference/gid_to_lid_change_handler.h @@ -3,10 +3,10 @@ #pragma once #include "i_gid_to_lid_change_handler.h" -#include <vector> -#include <mutex> #include <vespa/vespalib/stllike/hash_map.h> #include <vespa/document/base/globalid.h> +#include <vector> +#include <mutex> namespace searchcorespi { namespace index { struct IThreadService; } } @@ -41,28 +41,27 @@ class GidToLidChangeHandler : public std::enable_shared_from_this<GidToLidChange }; std::mutex _lock; - Listeners _listeners; - bool _closed; + Listeners _listeners; + bool _closed; vespalib::hash_map<GlobalId, PendingRemoveEntry, GlobalId::hash> _pendingRemove; - void notifyPutDone(GlobalId gid, uint32_t lid); - void notifyRemove(GlobalId gid); + void notifyPutDone(Context context, GlobalId gid, uint32_t lid); + void notifyRemove(Context context, GlobalId gid); public: GidToLidChangeHandler(); - virtual ~GidToLidChangeHandler(); + ~GidToLidChangeHandler() override; - virtual void notifyPutDone(GlobalId gid, uint32_t lid, SerialNum serialNum) override; - virtual void notifyRemove(GlobalId gid, SerialNum serialNum) override; - virtual void notifyRemoveDone(GlobalId gid, SerialNum serialNum) override; + void notifyPutDone(Context context, GlobalId gid, uint32_t lid, SerialNum serialNum) override; + void notifyRemove(Context context, GlobalId gid, SerialNum serialNum) override; + void notifyRemoveDone(GlobalId gid, SerialNum serialNum) override; /** * Close handler, further notifications are blocked. */ void close(); - virtual void addListener(std::unique_ptr<IGidToLidChangeListener> listener) override; - virtual void removeListeners(const vespalib::string &docTypeName, - const std::set<vespalib::string> &keepNames) override; + void addListener(std::unique_ptr<IGidToLidChangeListener> listener) override; + void removeListeners(const vespalib::string &docTypeName, const std::set<vespalib::string> &keepNames) override; }; } // namespace proton diff --git a/searchcore/src/vespa/searchcore/proton/reference/gid_to_lid_change_listener.cpp b/searchcore/src/vespa/searchcore/proton/reference/gid_to_lid_change_listener.cpp index 57e284cc61b..ac1f910b902 100644 --- a/searchcore/src/vespa/searchcore/proton/reference/gid_to_lid_change_listener.cpp +++ b/searchcore/src/vespa/searchcore/proton/reference/gid_to_lid_change_listener.cpp @@ -25,23 +25,23 @@ GidToLidChangeListener::~GidToLidChangeListener() } void -GidToLidChangeListener::notifyPutDone(document::GlobalId gid, uint32_t lid) +GidToLidChangeListener::notifyPutDone(Context context, document::GlobalId gid, uint32_t lid) { - std::promise<void> promise; - auto future = promise.get_future(); _attributeFieldWriter.executeLambda(_executorId, - [this, &promise, gid, lid]() { _attr->notifyReferencedPut(gid, lid); promise.set_value(); }); - future.wait(); + [this, context=std::move(context), gid, lid]() { + (void) context; + _attr->notifyReferencedPut(gid, lid); + }); } void -GidToLidChangeListener::notifyRemove(document::GlobalId gid) +GidToLidChangeListener::notifyRemove(Context context, document::GlobalId gid) { - std::promise<void> promise; - auto future = promise.get_future(); _attributeFieldWriter.executeLambda(_executorId, - [this, &promise, gid]() { _attr->notifyReferencedRemove(gid); promise.set_value(); }); - future.wait(); + [this, context = std::move(context), gid]() { + (void) context; + _attr->notifyReferencedRemove(gid); + }); } void @@ -50,7 +50,10 @@ GidToLidChangeListener::notifyRegistered() std::promise<void> promise; auto future = promise.get_future(); _attributeFieldWriter.executeLambda(_executorId, - [this, &promise]() { _attr->populateTargetLids(); promise.set_value(); }); + [this, &promise]() { + _attr->populateTargetLids(); + promise.set_value(); + }); future.wait(); } diff --git a/searchcore/src/vespa/searchcore/proton/reference/gid_to_lid_change_listener.h b/searchcore/src/vespa/searchcore/proton/reference/gid_to_lid_change_listener.h index 7b033b9899f..326513e6367 100644 --- a/searchcore/src/vespa/searchcore/proton/reference/gid_to_lid_change_listener.h +++ b/searchcore/src/vespa/searchcore/proton/reference/gid_to_lid_change_listener.h @@ -29,8 +29,8 @@ public: const vespalib::string &name, const vespalib::string &docTypeName); ~GidToLidChangeListener() override; - void notifyPutDone(document::GlobalId gid, uint32_t lid) override; - void notifyRemove(document::GlobalId gid) override; + void notifyPutDone(Context context, document::GlobalId gid, uint32_t lid) override; + void notifyRemove(Context context, document::GlobalId gid) override; void notifyRegistered() override; const vespalib::string &getName() const override; const vespalib::string &getDocTypeName() const override; diff --git a/searchcore/src/vespa/searchcore/proton/reference/i_gid_to_lid_change_handler.h b/searchcore/src/vespa/searchcore/proton/reference/i_gid_to_lid_change_handler.h index 7de837236e8..0e64827d969 100644 --- a/searchcore/src/vespa/searchcore/proton/reference/i_gid_to_lid_change_handler.h +++ b/searchcore/src/vespa/searchcore/proton/reference/i_gid_to_lid_change_handler.h @@ -2,17 +2,14 @@ #pragma once -#include <set> -#include <memory> -#include <vespa/vespalib/stllike/string.h> +#include "i_gid_to_lid_change_listener.h" #include <vespa/searchlib/common/serialnum.h> +#include <set> namespace document { class GlobalId; } namespace proton { -class IGidToLidChangeListener; - /* * Interface class for registering listeners that get notification when * gid to lid mapping changes. @@ -20,6 +17,7 @@ class IGidToLidChangeListener; class IGidToLidChangeHandler { public: + using Context = IGidToLidChangeListener::Context; using SerialNum = search::SerialNum; using GlobalId = document::GlobalId; @@ -40,8 +38,8 @@ public: /** * Notify gid to lid mapping change. */ - virtual void notifyPutDone(GlobalId gid, uint32_t lid, SerialNum serialNum) = 0; - virtual void notifyRemove(GlobalId gid, SerialNum serialNum) = 0; + virtual void notifyPutDone(Context context, GlobalId gid, uint32_t lid, SerialNum serialNum) = 0; + virtual void notifyRemove(Context context, GlobalId gid, SerialNum serialNum) = 0; virtual void notifyRemoveDone(GlobalId gid, SerialNum serialNum) = 0; }; diff --git a/searchcore/src/vespa/searchcore/proton/reference/i_gid_to_lid_change_listener.h b/searchcore/src/vespa/searchcore/proton/reference/i_gid_to_lid_change_listener.h index ebae8d40611..d997c87305b 100644 --- a/searchcore/src/vespa/searchcore/proton/reference/i_gid_to_lid_change_listener.h +++ b/searchcore/src/vespa/searchcore/proton/reference/i_gid_to_lid_change_listener.h @@ -2,7 +2,7 @@ #pragma once -#include <stdint.h> +#include <vespa/searchlib/common/idestructorcallback.h> #include <vespa/vespalib/stllike/string.h> namespace document { class GlobalId; } @@ -16,9 +16,10 @@ namespace proton { class IGidToLidChangeListener { public: + using Context = std::shared_ptr<search::IDestructorCallback>; virtual ~IGidToLidChangeListener() { } - virtual void notifyPutDone(document::GlobalId gid, uint32_t lid) = 0; - virtual void notifyRemove(document::GlobalId gid) = 0; + virtual void notifyPutDone(Context context, document::GlobalId gid, uint32_t lid) = 0; + virtual void notifyRemove(Context context, document::GlobalId gid) = 0; virtual void notifyRegistered() = 0; virtual const vespalib::string &getName() const = 0; virtual const vespalib::string &getDocTypeName() const = 0; diff --git a/searchcore/src/vespa/searchcore/proton/server/operationdonecontext.h b/searchcore/src/vespa/searchcore/proton/server/operationdonecontext.h index 4c310abf871..64644b099a6 100644 --- a/searchcore/src/vespa/searchcore/proton/server/operationdonecontext.h +++ b/searchcore/src/vespa/searchcore/proton/server/operationdonecontext.h @@ -19,6 +19,7 @@ class OperationDoneContext : public search::IDestructorCallback FeedToken _token; protected: void ack(); + FeedToken steal() { return std::move(_token); } public: OperationDoneContext(FeedToken token); diff --git a/searchcore/src/vespa/searchcore/proton/server/putdonecontext.cpp b/searchcore/src/vespa/searchcore/proton/server/putdonecontext.cpp index 45597bef86f..0af9101f826 100644 --- a/searchcore/src/vespa/searchcore/proton/server/putdonecontext.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/putdonecontext.cpp @@ -30,7 +30,7 @@ PutDoneContext::~PutDoneContext() _docIdLimit->bumpUpLimit(_lid + 1); } if (_enableNotifyPut) { - _gidToLidChangeHandler.notifyPutDone(_gid, _lid, _serialNum); + _gidToLidChangeHandler.notifyPutDone(steal(), _gid, _lid, _serialNum); } } diff --git a/searchcore/src/vespa/searchcore/proton/server/putdonecontext.h b/searchcore/src/vespa/searchcore/proton/server/putdonecontext.h index 47f5b944051..a2d60c856ba 100644 --- a/searchcore/src/vespa/searchcore/proton/server/putdonecontext.h +++ b/searchcore/src/vespa/searchcore/proton/server/putdonecontext.h @@ -22,12 +22,12 @@ class IGidToLidChangeHandler; */ class PutDoneContext : public OperationDoneContext { - uint32_t _lid; - DocIdLimit *_docIdLimit; + uint32_t _lid; + DocIdLimit *_docIdLimit; IGidToLidChangeHandler &_gidToLidChangeHandler; - document::GlobalId _gid; - search::SerialNum _serialNum; - bool _enableNotifyPut; + document::GlobalId _gid; + search::SerialNum _serialNum; + bool _enableNotifyPut; std::shared_ptr<const document::Document> _doc; public: @@ -39,5 +39,4 @@ public: void registerPutLid(DocIdLimit *docIdLimit) { _docIdLimit = docIdLimit; } }; - } // namespace proton diff --git a/searchcore/src/vespa/searchcore/proton/server/storeonlyfeedview.cpp b/searchcore/src/vespa/searchcore/proton/server/storeonlyfeedview.cpp index bee8a0e0473..6e243951386 100644 --- a/searchcore/src/vespa/searchcore/proton/server/storeonlyfeedview.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/storeonlyfeedview.cpp @@ -18,6 +18,7 @@ #include <vespa/searchcore/proton/documentmetastore/ilidreusedelayer.h> #include <vespa/searchcore/proton/feedoperation/operations.h> #include <vespa/searchcore/proton/reference/i_gid_to_lid_change_handler.h> +#include <vespa/searchlib/common/gatecallback.h> #include <vespa/vespalib/util/isequencedtaskexecutor.h> #include <vespa/vespalib/util/exceptions.h> @@ -632,8 +633,10 @@ StoreOnlyFeedView::adjustMetaStore(const DocumentOperation &op, const GlobalId & putMetaData(_metaStore, docId, op, _params._subDbType == SubDbType::REMOVED); } } else if (op.getValidPrevDbdId(_params._subDbId)) { - _gidToLidChangeHandler.notifyRemove(gid, serialNum); + vespalib::Gate gate; + _gidToLidChangeHandler.notifyRemove(std::make_shared<search::GateCallback>(gate), gid, serialNum); pendingNotifyRemoveDone.setup(_gidToLidChangeHandler, gid, serialNum); + gate.await(); removeMetaData(_metaStore, gid, docId, op, _params._subDbType == SubDbType::REMOVED); } _metaStore.commit(serialNum, serialNum); @@ -664,10 +667,15 @@ StoreOnlyFeedView::removeDocuments(const RemoveDocumentsOperation &op, bool remo bool explicitReuseLids = false; std::vector<document::GlobalId> gidsToRemove; if (useDMS) { + vespalib::Gate gate; gidsToRemove = getGidsToRemove(_metaStore, lidsToRemove); - for (const auto &gid : gidsToRemove) { - _gidToLidChangeHandler.notifyRemove(gid, serialNum); + { + IGidToLidChangeHandler::Context context = std::make_shared<search::GateCallback>(gate); + for (const auto &gid : gidsToRemove) { + _gidToLidChangeHandler.notifyRemove(context, gid, serialNum); + } } + gate.await(); _metaStore.removeBatch(lidsToRemove, ctx->getDocIdLimit()); _metaStore.commit(serialNum, serialNum); explicitReuseLids = _lidReuseDelayer.delayReuse(lidsToRemove); diff --git a/searchcore/src/vespa/searchcore/proton/test/mock_gid_to_lid_change_handler.h b/searchcore/src/vespa/searchcore/proton/test/mock_gid_to_lid_change_handler.h index 169cc8e4f7a..69e4af49f5f 100644 --- a/searchcore/src/vespa/searchcore/proton/test/mock_gid_to_lid_change_handler.h +++ b/searchcore/src/vespa/searchcore/proton/test/mock_gid_to_lid_change_handler.h @@ -31,21 +31,20 @@ public: { } - ~MockGidToLidChangeHandler() { } + ~MockGidToLidChangeHandler() override { } - virtual void addListener(std::unique_ptr<IGidToLidChangeListener> listener) override { + void addListener(std::unique_ptr<IGidToLidChangeListener> listener) override { _adds.emplace_back(listener->getDocTypeName(), listener->getName()); _listeners.push_back(std::move(listener)); } - virtual void removeListeners(const vespalib::string &docTypeName, - const std::set<vespalib::string> &keepNames) override { + void removeListeners(const vespalib::string &docTypeName, const std::set<vespalib::string> &keepNames) override { _removes.emplace_back(docTypeName, keepNames); } - virtual void notifyPutDone(document::GlobalId, uint32_t, SerialNum) override { } - virtual void notifyRemove(document::GlobalId, SerialNum) override { } - virtual void notifyRemoveDone(document::GlobalId, SerialNum) override { } + void notifyPutDone(Context, document::GlobalId, uint32_t, SerialNum) override { } + void notifyRemove(Context, document::GlobalId, SerialNum) override { } + void notifyRemoveDone(document::GlobalId, SerialNum) override { } void assertAdds(const std::vector<AddEntry> &expAdds) { |