aboutsummaryrefslogtreecommitdiffstats
path: root/searchcore
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2019-01-25 11:08:14 +0100
committerGitHub <noreply@github.com>2019-01-25 11:08:14 +0100
commit249a84e81975da898ebf9a4a7c79e585a06ae8f7 (patch)
tree51debbc63220d472b97af98fe5703a9a2db887f5 /searchcore
parentfa25375f1d489f6fd602140bddb40176acc63c2b (diff)
parentb1079b193ac984cb91bc625298e8157fbe0e9361 (diff)
Merge pull request #8228 from vespa-engine/balder/close-documentdb-in-parallell
Allow faster shutdown by using more threads
Diffstat (limited to 'searchcore')
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/proton.cpp25
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/proton.h1
2 files changed, 21 insertions, 5 deletions
diff --git a/searchcore/src/vespa/searchcore/proton/server/proton.cpp b/searchcore/src/vespa/searchcore/proton/server/proton.cpp
index 09e5a64185a..57f36d10745 100644
--- a/searchcore/src/vespa/searchcore/proton/server/proton.cpp
+++ b/searchcore/src/vespa/searchcore/proton/server/proton.cpp
@@ -29,6 +29,7 @@
#include <vespa/document/repo/documenttyperepo.h>
#include <vespa/vespalib/io/fileutil.h>
#include <vespa/vespalib/util/closuretask.h>
+#include <vespa/vespalib/util/lambdatask.h>
#include <vespa/vespalib/util/host_name.h>
#include <vespa/vespalib/util/random.h>
#include <vespa/searchlib/engine/transportserver.h>
@@ -44,6 +45,7 @@ using document::DocumentTypeRepo;
using vespalib::FileHeader;
using vespalib::IllegalStateException;
using vespalib::Slime;
+using vespalib::makeLambdaTask;
using vespalib::slime::ArrayInserter;
using vespalib::slime::Cursor;
@@ -112,7 +114,7 @@ Proton::ProtonFileHeaderContext::ProtonFileHeaderContext(const Proton &proton_,
assert(!_hostName.empty());
}
-Proton::ProtonFileHeaderContext::~ProtonFileHeaderContext() { }
+Proton::ProtonFileHeaderContext::~ProtonFileHeaderContext() = default;
void
Proton::ProtonFileHeaderContext::addTags(vespalib::GenericHeader &header,
@@ -432,10 +434,9 @@ Proton::~Proton()
if (_fs4Server) {
_fs4Server->shutDown();
}
- while (!_documentDBMap.empty()) {
- const DocTypeName docTypeName(_documentDBMap.begin()->first);
- removeDocumentDB(docTypeName);
- }
+ size_t numCores = _protonConfigurer.getActiveConfigSnapshot()->getBootstrapConfig()->getHwInfo().cpu().cores();
+ vespalib::ThreadStackExecutor closePool(std::min(_documentDBMap.size(), numCores), 0x20000);
+ closeDocumentDBs(closePool);
_documentDBMap.clear();
_persistenceEngine.reset();
_tls.reset();
@@ -445,6 +446,20 @@ Proton::~Proton()
LOG(debug, "Explicit destructor done");
}
+void
+Proton::closeDocumentDBs(vespalib::ThreadStackExecutorBase & executor) {
+ // Need to extract names first as _documentDBMap is modified while removing.
+ std::vector<DocTypeName> docTypes;
+ docTypes.reserve(_documentDBMap.size());
+ for (const auto & entry : _documentDBMap) {
+ docTypes.push_back(entry.first);
+ }
+ for (const auto & docTypeName : docTypes) {
+ executor.execute(makeLambdaTask([this, docTypeName]() { removeDocumentDB(docTypeName); }));
+ }
+ executor.sync();
+}
+
size_t Proton::getNumDocs() const
{
size_t numDocs(0);
diff --git a/searchcore/src/vespa/searchcore/proton/server/proton.h b/searchcore/src/vespa/searchcore/proton/server/proton.h
index 7dd4630360a..39e32c7f504 100644
--- a/searchcore/src/vespa/searchcore/proton/server/proton.h
+++ b/searchcore/src/vespa/searchcore/proton/server/proton.h
@@ -154,6 +154,7 @@ private:
BootstrapConfig::SP getActiveConfigSnapshot() const;
std::shared_ptr<IDocumentDBReferenceRegistry> getDocumentDBReferenceRegistry() const override;
bool updateNodeUp(BucketSpace bucketSpace, bool nodeUpInBucketSpace);
+ void closeDocumentDBs(vespalib::ThreadStackExecutorBase & executor);
public:
typedef std::unique_ptr<Proton> UP;
typedef std::shared_ptr<Proton> SP;