From 687168ef6c34e7b4ad060f88e54c0182b3938ab2 Mon Sep 17 00:00:00 2001 From: Henning Baldersheim Date: Sat, 30 Jan 2021 22:26:07 +0000 Subject: Non-empty _pendingPrune will shortcut throttleing when doing flushAll. That is done on triggerFlush and prepareForRestart. That is incorrect as it causes a memory surge. --- .../src/vespa/searchcore/proton/flushengine/flushengine.cpp | 8 ++++---- 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 &guard) const } bool -FlushEngine::wait(vespalib::duration minimumWaitTimeIfReady) +FlushEngine::wait(vespalib::duration minimumWaitTimeIfReady, bool ignorePendingPrune) { std::unique_lock 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(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 &guard) const; - bool wait(vespalib::duration minimumWaitTimeIfReady); + bool wait(vespalib::duration minimumWaitTimeIfReady, bool considerPendingPrune); bool isFlushing(const std::lock_guard &guard, const vespalib::string & name) const; friend class FlushTask; -- cgit v1.2.3