diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2021-01-31 17:40:40 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-31 17:40:40 +0100 |
commit | 5ac0d0b71749c7555167c3c3906ff6843bf178f0 (patch) | |
tree | 28686159e6ff3df2a5dd833e647bcaa8fa14fc1d | |
parent | fb5725fb210d96048618edd41a8c4ffa0308125e (diff) | |
parent | 687168ef6c34e7b4ad060f88e54c0182b3938ab2 (diff) |
Merge pull request #16296 from vespa-engine/balder/also-throttle-trigger-flush-and-prepare-for-restart
Non-empty _pendingPrune will shortcut throttleing when doing flushAll.
-rw-r--r-- | searchcore/src/vespa/searchcore/proton/flushengine/flushengine.cpp | 8 | ||||
-rw-r--r-- | searchcore/src/vespa/searchcore/proton/flushengine/flushengine.h | 2 |
2 files changed, 5 insertions, 5 deletions
diff --git a/searchcore/src/vespa/searchcore/proton/flushengine/flushengine.cpp b/searchcore/src/vespa/searchcore/proton/flushengine/flushengine.cpp index b4ab34d6866..29fa2c95945 100644 --- a/searchcore/src/vespa/searchcore/proton/flushengine/flushengine.cpp +++ b/searchcore/src/vespa/searchcore/proton/flushengine/flushengine.cpp @@ -151,13 +151,13 @@ FlushEngine::canFlushMore(const std::unique_lock<std::mutex> &guard) const } bool -FlushEngine::wait(vespalib::duration minimumWaitTimeIfReady) +FlushEngine::wait(vespalib::duration minimumWaitTimeIfReady, bool ignorePendingPrune) { std::unique_lock<std::mutex> guard(_lock); if ( (minimumWaitTimeIfReady != vespalib::duration::zero()) && canFlushMore(guard) && _pendingPrune.empty()) { _cond.wait_for(guard, minimumWaitTimeIfReady); } - while ( ! canFlushMore(guard) && _pendingPrune.empty()) { + while ( ! canFlushMore(guard) && ( ignorePendingPrune || _pendingPrune.empty())) { _cond.wait_for(guard, 1s); // broadcast when flush done } return !_closed; @@ -168,7 +168,7 @@ FlushEngine::Run(FastOS_ThreadInterface *, void *) { bool shouldIdle = false; vespalib::string prevFlushName; - while (wait(shouldIdle ? _idleInterval : vespalib::duration::zero())) { + while (wait(shouldIdle ? _idleInterval : vespalib::duration::zero(), false)) { shouldIdle = false; if (prune()) { continue; // Prune attempted on one or more handlers @@ -307,7 +307,7 @@ FlushEngine::flushAll(const FlushContext::List &lst) { LOG(debug, "%ld targets to flush.", lst.size()); for (const FlushContext::SP & ctx : lst) { - if (wait(vespalib::duration::zero())) { + if (wait(vespalib::duration::zero(), true)) { if (ctx->initFlush(get_flush_token(*ctx))) { logTarget("initiated", *ctx); _executor.execute(std::make_unique<FlushTask>(initFlush(*ctx), *this, ctx)); diff --git a/searchcore/src/vespa/searchcore/proton/flushengine/flushengine.h b/searchcore/src/vespa/searchcore/proton/flushengine/flushengine.h index e4d9e269215..e4f3cc8edc2 100644 --- a/searchcore/src/vespa/searchcore/proton/flushengine/flushengine.h +++ b/searchcore/src/vespa/searchcore/proton/flushengine/flushengine.h @@ -79,7 +79,7 @@ private: uint32_t initFlush(const IFlushHandler::SP &handler, const IFlushTarget::SP &target); void flushDone(const FlushContext &ctx, uint32_t taskId); bool canFlushMore(const std::unique_lock<std::mutex> &guard) const; - bool wait(vespalib::duration minimumWaitTimeIfReady); + bool wait(vespalib::duration minimumWaitTimeIfReady, bool considerPendingPrune); bool isFlushing(const std::lock_guard<std::mutex> &guard, const vespalib::string & name) const; friend class FlushTask; |