summaryrefslogtreecommitdiffstats
path: root/searchcore
diff options
context:
space:
mode:
Diffstat (limited to 'searchcore')
-rw-r--r--searchcore/src/tests/proton/documentdb/documentbucketmover/documentbucketmover_test.cpp8
-rw-r--r--searchcore/src/tests/proton/documentdb/lid_space_compaction/lid_space_compaction_test.cpp70
-rw-r--r--searchcore/src/tests/proton/documentdb/maintenancecontroller/maintenancecontroller_test.cpp5
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/bucketmovejob.cpp12
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/documentbucketmover.cpp12
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/documentdb.cpp22
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/documentsubdbcollection.cpp27
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/lid_space_compaction_handler.cpp27
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/lid_space_compaction_handler.h12
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/maintenance_jobs_injector.cpp4
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/maintenancecontroller.cpp20
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/maintenancedocumentsubdb.cpp45
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/maintenancedocumentsubdb.h28
13 files changed, 174 insertions, 118 deletions
diff --git a/searchcore/src/tests/proton/documentdb/documentbucketmover/documentbucketmover_test.cpp b/searchcore/src/tests/proton/documentdb/documentbucketmover/documentbucketmover_test.cpp
index af6a9d38385..10b1c829674 100644
--- a/searchcore/src/tests/proton/documentdb/documentbucketmover/documentbucketmover_test.cpp
+++ b/searchcore/src/tests/proton/documentdb/documentbucketmover/documentbucketmover_test.cpp
@@ -191,7 +191,7 @@ MySubDb::MySubDb(const std::shared_ptr<const DocumentTypeRepo> &repo, std::share
_metaStore(*_metaStoreSP),
_realRetriever(std::make_shared<MyDocumentRetriever>(repo)),
_retriever(_realRetriever),
- _subDb(_metaStoreSP, _retriever, subDbId), _docs(),
+ _subDb("my_sub_db", subDbId, _metaStoreSP, _retriever, IFeedView::SP()), _docs(),
_bucketDBHandler(*bucketDB)
{
_bucketDBHandler.addDocumentMetaStore(_metaStoreSP.get(), 0);
@@ -238,7 +238,11 @@ struct MoveFixture
void setupForBucket(const BucketId &bucket,
uint32_t sourceSubDbId,
uint32_t targetSubDbId) {
- _source._subDb._subDbId = sourceSubDbId;
+ _source._subDb = MaintenanceDocumentSubDB(_source._subDb.name(),
+ sourceSubDbId,
+ _source._subDb.meta_store(),
+ _source._subDb.retriever(),
+ _source._subDb.feed_view());
_mover.setupForBucket(bucket, &_source._subDb, targetSubDbId, _handler, _bucketDb);
}
void moveDocuments(size_t maxDocsToMove) {
diff --git a/searchcore/src/tests/proton/documentdb/lid_space_compaction/lid_space_compaction_test.cpp b/searchcore/src/tests/proton/documentdb/lid_space_compaction/lid_space_compaction_test.cpp
index 82566025a30..5305ff15003 100644
--- a/searchcore/src/tests/proton/documentdb/lid_space_compaction/lid_space_compaction_test.cpp
+++ b/searchcore/src/tests/proton/documentdb/lid_space_compaction/lid_space_compaction_test.cpp
@@ -160,51 +160,59 @@ struct MyFrozenBucketHandler : public IFrozenBucketHandler
virtual void removeListener(IBucketFreezeListener *) override { }
};
-struct MyFeedView : public test::DummyFeedView
-{
- MyFeedView(const std::shared_ptr<const DocumentTypeRepo> &repo)
- : test::DummyFeedView(repo)
+struct MyFeedView : public test::DummyFeedView {
+ MyFeedView(std::shared_ptr<const DocumentTypeRepo> repo)
+ : test::DummyFeedView(std::move(repo))
{
}
};
-struct MyDocumentStore : public test::DummyDocumentStore
-{
+struct MyDocumentStore : public test::DummyDocumentStore {
Document::SP _readDoc;
mutable uint32_t _readLid;
MyDocumentStore() : _readDoc(), _readLid(0) {}
- virtual document::Document::UP
- read(search::DocumentIdT lid, const document::DocumentTypeRepo &) const override {
+ ~MyDocumentStore();
+ document::Document::UP read(search::DocumentIdT lid, const document::DocumentTypeRepo &) const override {
_readLid = lid;
return Document::UP(_readDoc->clone());
}
};
-struct MySummaryManager : public test::DummySummaryManager
-{
- MyDocumentStore _store;
- MySummaryManager() : _store() {}
- virtual search::IDocumentStore &getBackingStore() override { return _store; }
-};
+MyDocumentStore::~MyDocumentStore() = default;
-struct MySubDb : public test::DummyDocumentSubDb
-{
- std::shared_ptr<const DocumentTypeRepo> _repo;
- MySubDb(const std::shared_ptr<const DocumentTypeRepo> &repo, std::shared_ptr<BucketDBOwner> bucketDB);
- ~MySubDb();
- virtual IFeedView::SP getFeedView() const override {
- return IFeedView::SP(new MyFeedView(_repo));
+struct MyDocumentRetriever : public DocumentRetrieverBaseForTest {
+ std::shared_ptr<const DocumentTypeRepo> repo;
+ const MyDocumentStore& store;
+ MyDocumentRetriever(std::shared_ptr<const DocumentTypeRepo> repo_in, const MyDocumentStore& store_in)
+ : repo(repo_in),
+ store(store_in)
+ {
+ }
+ const document::DocumentTypeRepo& getDocumentTypeRepo() const override { return *repo; }
+ void getBucketMetaData(const storage::spi::Bucket&, DocumentMetaData::Vector& ) const override { abort(); }
+ DocumentMetaData getDocumentMetaData(const DocumentId& ) const override { abort(); }
+ Document::UP getDocument(DocumentIdT lid) const override {
+ return store.read(lid, *repo);
}
+ CachedSelect::SP parseSelect(const vespalib::string &) const override { abort(); }
};
+struct MySubDb {
+ test::DummyDocumentSubDb sub_db;
+ MaintenanceDocumentSubDB maintenance_sub_db;
+ MySubDb(std::shared_ptr<BucketDBOwner> bucket_db, const MyDocumentStore& store, std::shared_ptr<const DocumentTypeRepo> repo);
+ ~MySubDb();
+};
-MySubDb::MySubDb(const std::shared_ptr<const DocumentTypeRepo> &repo, std::shared_ptr<BucketDBOwner> bucketDB)
- : test::DummyDocumentSubDb(bucketDB, SUBDB_ID),
- _repo(repo)
+MySubDb::MySubDb(std::shared_ptr<BucketDBOwner> bucket_db, const MyDocumentStore& store, std::shared_ptr<const DocumentTypeRepo> repo)
+ : sub_db(std::move(bucket_db), SUBDB_ID),
+ maintenance_sub_db(sub_db.getName(), sub_db.getSubDbId(), sub_db.getDocumentMetaStoreContext().getSP(),
+ std::make_shared<MyDocumentRetriever>(repo, store),
+ std::make_shared<MyFeedView>(repo))
{
- _summaryManager.reset(new MySummaryManager());
}
-MySubDb::~MySubDb() {}
+
+MySubDb::~MySubDb() = default;
struct MyDirectJobRunner : public IMaintenanceJobRunner {
IMaintenanceJob &_job;
@@ -350,17 +358,15 @@ struct HandlerFixture
{
DocBuilder _docBuilder;
std::shared_ptr<BucketDBOwner> _bucketDB;
+ MyDocumentStore _docStore;
MySubDb _subDb;
- MySummaryManager &_summaryMgr;
- MyDocumentStore &_docStore;
LidSpaceCompactionHandler _handler;
HandlerFixture()
: _docBuilder(Schema()),
_bucketDB(std::make_shared<BucketDBOwner>()),
- _subDb(_docBuilder.getDocumentTypeRepo(), _bucketDB),
- _summaryMgr(static_cast<MySummaryManager &>(*_subDb.getSummaryManager())),
- _docStore(_summaryMgr._store),
- _handler(_subDb, "test")
+ _docStore(),
+ _subDb(_bucketDB, _docStore, _docBuilder.getDocumentTypeRepo()),
+ _handler(_subDb.maintenance_sub_db, "test")
{
_docStore._readDoc = _docBuilder.startDocument(DOC_ID).endDocument();
}
diff --git a/searchcore/src/tests/proton/documentdb/maintenancecontroller/maintenancecontroller_test.cpp b/searchcore/src/tests/proton/documentdb/maintenancecontroller/maintenancecontroller_test.cpp
index c3974368e54..a4f2aeb767d 100644
--- a/searchcore/src/tests/proton/documentdb/maintenancecontroller/maintenancecontroller_test.cpp
+++ b/searchcore/src/tests/proton/documentdb/maintenancecontroller/maintenancecontroller_test.cpp
@@ -523,9 +523,10 @@ MyDocumentSubDB::getSubDB()
{
IDocumentRetriever::SP retriever(new MyDocumentRetriever(*this));
- return MaintenanceDocumentSubDB(_metaStoreSP,
+ return MaintenanceDocumentSubDB("my_sub_db", _subDBId,
+ _metaStoreSP,
retriever,
- _subDBId);
+ IFeedView::SP());
}
diff --git a/searchcore/src/vespa/searchcore/proton/server/bucketmovejob.cpp b/searchcore/src/vespa/searchcore/proton/server/bucketmovejob.cpp
index cb929e0a6c7..4848c5a5d47 100644
--- a/searchcore/src/vespa/searchcore/proton/server/bucketmovejob.cpp
+++ b/searchcore/src/vespa/searchcore/proton/server/bucketmovejob.cpp
@@ -88,9 +88,9 @@ BucketMoveJob::checkBucket(const BucketId &bucket,
const MaintenanceDocumentSubDB &source(wantReady ? _notReady : _ready);
const MaintenanceDocumentSubDB &target(wantReady ? _ready : _notReady);
LOG(debug, "checkBucket(): mover.setupForBucket(%s, source:%u, target:%u)",
- bucket.toString().c_str(), source._subDbId, target._subDbId);
- mover.setupForBucket(bucket, &source, target._subDbId,
- _moveHandler, _ready._metaStore->getBucketDB());
+ bucket.toString().c_str(), source.sub_db_id(), target.sub_db_id());
+ mover.setupForBucket(bucket, &source, target.sub_db_id(),
+ _moveHandler, _ready.meta_store()->getBucketDB());
}
BucketMoveJob::ScanResult
@@ -98,7 +98,7 @@ BucketMoveJob::scanBuckets(size_t maxBucketsToScan, IFrozenBucketHandler::Exclus
{
size_t bucketsScanned = 0;
bool passDone = false;
- ScanIterator itr(_ready._metaStore->getBucketDB().takeGuard(),
+ ScanIterator itr(_ready.meta_store()->getBucketDB().takeGuard(),
_scanPass, _scanPos._lastBucket, _endPos._lastBucket);
BucketId bucket;
for (; itr.valid() &&
@@ -250,7 +250,7 @@ BucketMoveJob::deactivateBucket(BucketId bucket)
void
BucketMoveJob::activateBucket(BucketId bucket)
{
- BucketDBOwner::Guard notReadyBdb(_notReady._metaStore->getBucketDB().takeGuard());
+ BucketDBOwner::Guard notReadyBdb(_notReady.meta_store()->getBucketDB().takeGuard());
if (notReadyBdb->get(bucket).getDocumentCount() == 0) {
return; // notready bucket already empty. This is the normal case.
}
@@ -291,7 +291,7 @@ BucketMoveJob::scanAndMove(size_t maxBucketsToScan,
while (!_delayedBuckets.empty() && _delayedMover.bucketDone()) {
const BucketId bucket = *_delayedBuckets.begin();
_delayedBuckets.erase(_delayedBuckets.begin());
- ScanIterator itr(_ready._metaStore->getBucketDB().takeGuard(), bucket);
+ ScanIterator itr(_ready.meta_store()->getBucketDB().takeGuard(), bucket);
if (itr.getBucket() == bucket) {
checkBucket(bucket, itr, _delayedMover, bucketGuard);
}
diff --git a/searchcore/src/vespa/searchcore/proton/server/documentbucketmover.cpp b/searchcore/src/vespa/searchcore/proton/server/documentbucketmover.cpp
index 3c73532fbba..d6d8ba03a67 100644
--- a/searchcore/src/vespa/searchcore/proton/server/documentbucketmover.cpp
+++ b/searchcore/src/vespa/searchcore/proton/server/documentbucketmover.cpp
@@ -24,12 +24,12 @@ DocumentBucketMover::moveDocument(DocumentIdT lid,
const document::GlobalId &gid,
Timestamp timestamp)
{
- Document::SP doc(_source->_retriever->getDocument(lid).release());
+ Document::SP doc(_source->retriever()->getDocument(lid).release());
if (!doc || doc->getId().getGlobalId() != gid)
return; // Failed to retrieve document, removed or changed identity
// TODO(geirst): what if doc is NULL?
BucketId bucketId = _bucket.stripUnused();
- MoveOperation op(bucketId, timestamp, doc, DbDocumentId(_source->_subDbId, lid), _targetSubDbId);
+ MoveOperation op(bucketId, timestamp, doc, DbDocumentId(_source->sub_db_id(), lid), _targetSubDbId);
// We cache the bucket for the document we are going to move to avoid getting
// inconsistent bucket info (getBucketInfo()) while moving between ready and not-ready
@@ -103,16 +103,16 @@ DocumentBucketMover::moveDocuments(size_t maxDocsToMove)
if (_bucketDone) {
return;
}
- Iterator itr = (_lastGidValid ? _source->_metaStore->upperBound(_lastGid)
- : _source->_metaStore->lowerBound(_bucket));
- const Iterator end = _source->_metaStore->upperBound(_bucket);
+ Iterator itr = (_lastGidValid ? _source->meta_store()->upperBound(_lastGid)
+ : _source->meta_store()->lowerBound(_bucket));
+ const Iterator end = _source->meta_store()->upperBound(_bucket);
size_t docsMoved = 0;
size_t docsSkipped = 0; // In absence of a proper cost metric
typedef std::vector<MoveKey> MoveVec;
MoveVec toMove;
for (; itr != end && docsMoved < maxDocsToMove; ++itr) {
DocumentIdT lid = itr.getKey();
- const RawDocumentMetaData &metaData = _source->_metaStore->getRawMetaData(lid);
+ const RawDocumentMetaData &metaData = _source->meta_store()->getRawMetaData(lid);
if (metaData.getBucketUsedBits() != _bucket.getUsedBits()) {
++docsSkipped;
if (docsSkipped >= 50) {
diff --git a/searchcore/src/vespa/searchcore/proton/server/documentdb.cpp b/searchcore/src/vespa/searchcore/proton/server/documentdb.cpp
index 16e8d7ae90a..2729dbe01a5 100644
--- a/searchcore/src/vespa/searchcore/proton/server/documentdb.cpp
+++ b/searchcore/src/vespa/searchcore/proton/server/documentdb.cpp
@@ -1,5 +1,6 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+#include "bootstrapconfig.h"
#include "combiningfeedview.h"
#include "commit_and_wait_document_retriever.h"
#include "document_meta_store_read_guards.h"
@@ -7,29 +8,29 @@
#include "documentdb.h"
#include "documentdbconfigscout.h"
#include "idocumentdbowner.h"
+#include "idocumentsubdb.h"
#include "lid_space_compaction_handler.h"
#include "maintenance_jobs_injector.h"
#include "reconfig_params.h"
-#include "bootstrapconfig.h"
#include <vespa/document/repo/documenttyperepo.h>
-#include <vespa/searchcore/proton/metrics/executor_threading_service_stats.h>
+#include <vespa/searchcommon/common/schemaconfigurer.h>
#include <vespa/searchcore/proton/attribute/attribute_writer.h>
#include <vespa/searchcore/proton/attribute/imported_attributes_repo.h>
#include <vespa/searchcore/proton/common/eventlogger.h>
#include <vespa/searchcore/proton/common/statusreport.h>
+#include <vespa/searchcore/proton/docsummary/isummarymanager.h>
#include <vespa/searchcore/proton/feedoperation/noopoperation.h>
#include <vespa/searchcore/proton/index/index_writer.h>
#include <vespa/searchcore/proton/initializer/task_runner.h>
+#include <vespa/searchcore/proton/metrics/executor_threading_service_stats.h>
#include <vespa/searchcore/proton/metrics/metricswireservice.h>
-#include <vespa/searchcore/proton/reference/i_document_db_reference_resolver.h>
-#include <vespa/searchcore/proton/reference/i_document_db_reference_registry.h>
#include <vespa/searchcore/proton/reference/document_db_reference_resolver.h>
-#include <vespa/searchcore/proton/docsummary/isummarymanager.h>
+#include <vespa/searchcore/proton/reference/i_document_db_reference_registry.h>
+#include <vespa/searchcore/proton/reference/i_document_db_reference_resolver.h>
#include <vespa/searchlib/attribute/attributefactory.h>
#include <vespa/searchlib/attribute/configconverter.h>
#include <vespa/searchlib/engine/docsumreply.h>
#include <vespa/searchlib/engine/searchreply.h>
-#include <vespa/searchcommon/common/schemaconfigurer.h>
#include <vespa/vespalib/io/fileutil.h>
#include <vespa/vespalib/util/closuretask.h>
#include <vespa/vespalib/util/exceptions.h>
@@ -205,9 +206,12 @@ DocumentDB::DocumentDB(const vespalib::string &baseDir,
_clusterStateHandler.addClusterStateChangedHandler(this);
// Forward changes of cluster state to bucket handler
_clusterStateHandler.addClusterStateChangedHandler(&_bucketHandler);
- for (auto subDb : _subDBs) {
- _lidSpaceCompactionHandlers.push_back(std::make_unique<LidSpaceCompactionHandler>(*subDb, _docTypeName.getName()));
- }
+
+ // Lid space compaction handlers are added in the same order as sub dbs are defined in DocumentSubDbCollection.
+ _lidSpaceCompactionHandlers.push_back(std::make_unique<LidSpaceCompactionHandler>(_maintenanceController.getReadySubDB(), _docTypeName.getName()));
+ _lidSpaceCompactionHandlers.push_back(std::make_unique<LidSpaceCompactionHandler>(_maintenanceController.getRemSubDB(), _docTypeName.getName()));
+ _lidSpaceCompactionHandlers.push_back(std::make_unique<LidSpaceCompactionHandler>(_maintenanceController.getNotReadySubDB(), _docTypeName.getName()));
+
_writeFilter.setConfig(loaded_config->getMaintenanceConfigSP()->getAttributeUsageFilterConfig());
fastos::TimeStamp visibilityDelay = loaded_config->getMaintenanceConfigSP()->getVisibilityDelay();
_visibility.setVisibilityDelay(visibilityDelay);
diff --git a/searchcore/src/vespa/searchcore/proton/server/documentsubdbcollection.cpp b/searchcore/src/vespa/searchcore/proton/server/documentsubdbcollection.cpp
index 70e548e8c05..682719436f1 100644
--- a/searchcore/src/vespa/searchcore/proton/server/documentsubdbcollection.cpp
+++ b/searchcore/src/vespa/searchcore/proton/server/documentsubdbcollection.cpp
@@ -139,18 +139,21 @@ wrapRetriever(const IDocumentRetriever::SP &retriever, ICommitable &commit)
void DocumentSubDBCollection::maintenanceSync(MaintenanceController &mc, ICommitable &commit) {
RetrieversSP retrievers = getRetrievers();
- MaintenanceDocumentSubDB readySubDB(
- getReadySubDB()->getDocumentMetaStoreContext().getSP(),
- wrapRetriever((*retrievers)[_readySubDbId], commit),
- _readySubDbId);
- MaintenanceDocumentSubDB remSubDB(
- getRemSubDB()->getDocumentMetaStoreContext().getSP(),
- (*retrievers)[_remSubDbId],
- _remSubDbId);
- MaintenanceDocumentSubDB notReadySubDB(
- getNotReadySubDB()->getDocumentMetaStoreContext().getSP(),
- wrapRetriever((*retrievers)[_notReadySubDbId], commit),
- _notReadySubDbId);
+ MaintenanceDocumentSubDB readySubDB(getReadySubDB()->getName(),
+ _readySubDbId,
+ getReadySubDB()->getDocumentMetaStoreContext().getSP(),
+ wrapRetriever((*retrievers)[_readySubDbId], commit),
+ getReadySubDB()->getFeedView());
+ MaintenanceDocumentSubDB remSubDB(getRemSubDB()->getName(),
+ _remSubDbId,
+ getRemSubDB()->getDocumentMetaStoreContext().getSP(),
+ (*retrievers)[_remSubDbId],
+ getRemSubDB()->getFeedView());
+ MaintenanceDocumentSubDB notReadySubDB(getNotReadySubDB()->getName(),
+ _notReadySubDbId,
+ getNotReadySubDB()->getDocumentMetaStoreContext().getSP(),
+ wrapRetriever((*retrievers)[_notReadySubDbId], commit),
+ getNotReadySubDB()->getFeedView());
mc.syncSubDBs(readySubDB, remSubDB, notReadySubDB);
}
diff --git a/searchcore/src/vespa/searchcore/proton/server/lid_space_compaction_handler.cpp b/searchcore/src/vespa/searchcore/proton/server/lid_space_compaction_handler.cpp
index a77aa302fea..c4dc26a0875 100644
--- a/searchcore/src/vespa/searchcore/proton/server/lid_space_compaction_handler.cpp
+++ b/searchcore/src/vespa/searchcore/proton/server/lid_space_compaction_handler.cpp
@@ -16,8 +16,8 @@ using storage::spi::Timestamp;
namespace proton {
-LidSpaceCompactionHandler::LidSpaceCompactionHandler(IDocumentSubDB &subDb,
- const vespalib::string &docTypeName)
+LidSpaceCompactionHandler::LidSpaceCompactionHandler(const MaintenanceDocumentSubDB& subDb,
+ const vespalib::string& docTypeName)
: _subDb(subDb),
_docTypeName(docTypeName)
{
@@ -26,27 +26,24 @@ LidSpaceCompactionHandler::LidSpaceCompactionHandler(IDocumentSubDB &subDb,
LidUsageStats
LidSpaceCompactionHandler::getLidStatus() const
{
- return _subDb.getDocumentMetaStoreContext().get().getLidUsageStats();
+ return _subDb.meta_store()->getLidUsageStats();
}
IDocumentScanIterator::UP
LidSpaceCompactionHandler::getIterator() const
{
- return IDocumentScanIterator::UP(new DocumentScanIterator(
- _subDb.getDocumentMetaStoreContext().get()));
+ return std::make_unique<DocumentScanIterator>(*_subDb.meta_store());
}
MoveOperation::UP
LidSpaceCompactionHandler::createMoveOperation(const search::DocumentMetaData &document, uint32_t moveToLid) const
{
- IFeedView::SP feedView = _subDb.getFeedView();
- const ISummaryManager::SP &summaryMan = _subDb.getSummaryManager();
const uint32_t moveFromLid = document.lid;
- Document::UP doc = summaryMan->getBackingStore().read(moveFromLid, *feedView->getDocumentTypeRepo());
- MoveOperation::UP op(new MoveOperation(document.bucketId, document.timestamp,
- Document::SP(doc.release()),
- DbDocumentId(_subDb.getSubDbId(), moveFromLid),
- _subDb.getSubDbId()));
+ auto doc = _subDb.retriever()->getDocument(moveFromLid);
+ auto op = std::make_unique<MoveOperation>(document.bucketId, document.timestamp,
+ Document::SP(doc.release()),
+ DbDocumentId(_subDb.sub_db_id(), moveFromLid),
+ _subDb.sub_db_id());
op->setTargetLid(moveToLid);
return op;
}
@@ -54,14 +51,14 @@ LidSpaceCompactionHandler::createMoveOperation(const search::DocumentMetaData &d
void
LidSpaceCompactionHandler::handleMove(const MoveOperation& op, IDestructorCallback::SP doneCtx)
{
- _subDb.getFeedView()->handleMove(op, std::move(doneCtx));
+ _subDb.feed_view()->handleMove(op, std::move(doneCtx));
}
void
LidSpaceCompactionHandler::handleCompactLidSpace(const CompactLidSpaceOperation &op)
{
- assert(_subDb.getSubDbId() == op.getSubDbId());
- _subDb.getFeedView()->handleCompactLidSpace(op);
+ assert(_subDb.sub_db_id() == op.getSubDbId());
+ _subDb.feed_view()->handleCompactLidSpace(op);
}
} // namespace proton
diff --git a/searchcore/src/vespa/searchcore/proton/server/lid_space_compaction_handler.h b/searchcore/src/vespa/searchcore/proton/server/lid_space_compaction_handler.h
index 0861513a909..21d20001923 100644
--- a/searchcore/src/vespa/searchcore/proton/server/lid_space_compaction_handler.h
+++ b/searchcore/src/vespa/searchcore/proton/server/lid_space_compaction_handler.h
@@ -2,7 +2,7 @@
#pragma once
#include "i_lid_space_compaction_handler.h"
-#include "idocumentsubdb.h"
+#include "maintenancedocumentsubdb.h"
namespace proton {
@@ -12,18 +12,18 @@ namespace proton {
class LidSpaceCompactionHandler : public ILidSpaceCompactionHandler
{
private:
- IDocumentSubDB &_subDb;
+ const MaintenanceDocumentSubDB& _subDb;
vespalib::string _docTypeName;
public:
- LidSpaceCompactionHandler(IDocumentSubDB &subDb,
- const vespalib::string &docTypeName);
+ LidSpaceCompactionHandler(const MaintenanceDocumentSubDB& subDb,
+ const vespalib::string& docTypeName);
// Implements ILidSpaceCompactionHandler
virtual vespalib::string getName() const override {
- return _docTypeName + "." + _subDb.getName();
+ return _docTypeName + "." + _subDb.name();
}
- virtual uint32_t getSubDbId() const override { return _subDb.getSubDbId(); }
+ virtual uint32_t getSubDbId() const override { return _subDb.sub_db_id(); }
virtual search::LidUsageStats getLidStatus() const override;
virtual IDocumentScanIterator::UP getIterator() const override;
virtual MoveOperation::UP createMoveOperation(const search::DocumentMetaData &document, uint32_t moveToLid) const override;
diff --git a/searchcore/src/vespa/searchcore/proton/server/maintenance_jobs_injector.cpp b/searchcore/src/vespa/searchcore/proton/server/maintenance_jobs_injector.cpp
index 744ce2aa7f4..6b130dfa144 100644
--- a/searchcore/src/vespa/searchcore/proton/server/maintenance_jobs_injector.cpp
+++ b/searchcore/src/vespa/searchcore/proton/server/maintenance_jobs_injector.cpp
@@ -111,8 +111,8 @@ MaintenanceJobsInjector::injectJobs(MaintenanceController &controller,
controller.registerJobInMasterThread(MUP(new DocumentDBCommitJob(commit, config.getVisibilityDelay())));
}
const MaintenanceDocumentSubDB &mRemSubDB(controller.getRemSubDB());
- MUP pruneRDjob(new PruneRemovedDocumentsJob(config.getPruneRemovedDocumentsConfig(), *mRemSubDB._metaStore,
- mRemSubDB._subDbId, docTypeName, prdHandler, fbHandler));
+ MUP pruneRDjob(new PruneRemovedDocumentsJob(config.getPruneRemovedDocumentsConfig(), *mRemSubDB.meta_store(),
+ mRemSubDB.sub_db_id(), docTypeName, prdHandler, fbHandler));
controller.registerJobInMasterThread(
trackJob(jobTrackers.getRemovedDocumentsPrune(), std::move(pruneRDjob)));
if (!config.getLidSpaceCompactionConfig().isDisabled()) {
diff --git a/searchcore/src/vespa/searchcore/proton/server/maintenancecontroller.cpp b/searchcore/src/vespa/searchcore/proton/server/maintenancecontroller.cpp
index 79135d27e5c..e6afb8a19b2 100644
--- a/searchcore/src/vespa/searchcore/proton/server/maintenancecontroller.cpp
+++ b/searchcore/src/vespa/searchcore/proton/server/maintenancecontroller.cpp
@@ -197,6 +197,19 @@ MaintenanceController::newConfig(const DocumentDBMaintenanceConfig::SP &config)
restart();
}
+namespace {
+
+void
+assert_equal_meta_store_instances(const MaintenanceDocumentSubDB& old_db,
+ const MaintenanceDocumentSubDB& new_db)
+{
+ if (old_db.valid() && new_db.valid()) {
+ assert(old_db.meta_store().get() == new_db.meta_store().get());
+ }
+}
+
+}
+
void
MaintenanceController::syncSubDBs(const MaintenanceDocumentSubDB &readySubDB,
const MaintenanceDocumentSubDB &remSubDB,
@@ -206,11 +219,16 @@ MaintenanceController::syncSubDBs(const MaintenanceDocumentSubDB &readySubDB,
bool oldValid = _readySubDB.valid();
assert(readySubDB.valid());
assert(remSubDB.valid());
+ // Document meta store instances should not change. Maintenance jobs depend on this fact.
+ assert_equal_meta_store_instances(_readySubDB, readySubDB);
+ assert_equal_meta_store_instances(_remSubDB, remSubDB);
+ assert_equal_meta_store_instances(_notReadySubDB, notReadySubDB);
_readySubDB = readySubDB;
_remSubDB = remSubDB;
_notReadySubDB = notReadySubDB;
- if (!oldValid && _started)
+ if (!oldValid && _started) {
restart();
+ }
}
diff --git a/searchcore/src/vespa/searchcore/proton/server/maintenancedocumentsubdb.cpp b/searchcore/src/vespa/searchcore/proton/server/maintenancedocumentsubdb.cpp
index ffaea1ff576..6b781eb8e0f 100644
--- a/searchcore/src/vespa/searchcore/proton/server/maintenancedocumentsubdb.cpp
+++ b/searchcore/src/vespa/searchcore/proton/server/maintenancedocumentsubdb.cpp
@@ -5,26 +5,37 @@
namespace proton {
MaintenanceDocumentSubDB::MaintenanceDocumentSubDB()
- : _metaStore(),
- _retriever(),
- _subDbId(0u)
-{ }
+ : _name(""),
+ _sub_db_id(0),
+ _meta_store(nullptr),
+ _retriever(nullptr),
+ _feed_view(nullptr)
+{
+}
-MaintenanceDocumentSubDB::~MaintenanceDocumentSubDB() { }
+MaintenanceDocumentSubDB::~MaintenanceDocumentSubDB() = default;
-MaintenanceDocumentSubDB::MaintenanceDocumentSubDB(const IDocumentMetaStore::SP & metaStore,
- const IDocumentRetriever::SP & retriever,
- uint32_t subDbId)
- : _metaStore(metaStore),
- _retriever(retriever),
- _subDbId(subDbId)
-{ }
+MaintenanceDocumentSubDB::MaintenanceDocumentSubDB(const vespalib::string& name,
+ uint32_t sub_db_id,
+ IDocumentMetaStore::SP meta_store,
+ IDocumentRetriever::SP retriever,
+ IFeedView::SP feed_view)
+ : _name(name),
+ _sub_db_id(sub_db_id),
+ _meta_store(std::move(meta_store)),
+ _retriever(std::move(retriever)),
+ _feed_view(std::move(feed_view))
+{
+}
void
-MaintenanceDocumentSubDB::clear() {
- _metaStore.reset();
+MaintenanceDocumentSubDB::clear()
+{
+ _name = "";
+ _sub_db_id = 0;
+ _meta_store.reset();
_retriever.reset();
- _subDbId = 0u;
-}
+ _feed_view.reset();
+}
-} // namespace proton
+}
diff --git a/searchcore/src/vespa/searchcore/proton/server/maintenancedocumentsubdb.h b/searchcore/src/vespa/searchcore/proton/server/maintenancedocumentsubdb.h
index 41c43d910d7..bfe73f361b6 100644
--- a/searchcore/src/vespa/searchcore/proton/server/maintenancedocumentsubdb.h
+++ b/searchcore/src/vespa/searchcore/proton/server/maintenancedocumentsubdb.h
@@ -2,6 +2,7 @@
#pragma once
+#include "ifeedview.h"
#include <vespa/searchcore/proton/documentmetastore/i_document_meta_store.h>
#include <vespa/searchcore/proton/persistenceengine/i_document_retriever.h>
@@ -13,19 +14,30 @@ namespace proton {
*/
class MaintenanceDocumentSubDB
{
-public:
- IDocumentMetaStore::SP _metaStore;
- IDocumentRetriever::SP _retriever;
- uint32_t _subDbId;
+private:
+ vespalib::string _name;
+ uint32_t _sub_db_id;
+ IDocumentMetaStore::SP _meta_store;
+ IDocumentRetriever::SP _retriever;
+ IFeedView::SP _feed_view;
+public:
MaintenanceDocumentSubDB();
~MaintenanceDocumentSubDB();
- MaintenanceDocumentSubDB(const IDocumentMetaStore::SP & metaStore,
- const IDocumentRetriever::SP & retriever,
- uint32_t subDbId);
+ MaintenanceDocumentSubDB(const vespalib::string& name,
+ uint32_t sub_db_id,
+ IDocumentMetaStore::SP meta_store,
+ IDocumentRetriever::SP retriever,
+ IFeedView::SP feed_view);
+
+ const vespalib::string& name() const { return _name; }
+ uint32_t sub_db_id() const { return _sub_db_id; }
+ const IDocumentMetaStore::SP& meta_store() const { return _meta_store; }
+ const IDocumentRetriever::SP& retriever() const { return _retriever; }
+ const IFeedView::SP& feed_view() const { return _feed_view; }
- bool valid() const { return bool(_metaStore); }
+ bool valid() const { return _meta_store.get() != nullptr; }
void clear();
};