From 248557de9e06097d5c56f691f919c09f7a58e852 Mon Sep 17 00:00:00 2001 From: LaMont Nelson Date: Tue, 21 Dec 2021 20:59:26 +0000 Subject: SERVER-62204 do not schedule health check if observer is not enabled (cherry picked from commit 1b2cdb3b2f0ead76103cc518dc0e7102a98b1f48) --- src/mongo/db/process_health/fault_manager.cpp | 43 ++++++++++++--------------- 1 file changed, 19 insertions(+), 24 deletions(-) diff --git a/src/mongo/db/process_health/fault_manager.cpp b/src/mongo/db/process_health/fault_manager.cpp index 86290e0c05c..a3f2cd556e7 100644 --- a/src/mongo/db/process_health/fault_manager.cpp +++ b/src/mongo/db/process_health/fault_manager.cpp @@ -568,31 +568,26 @@ void FaultManager::healthCheck(HealthObserver* observer, std::shared_ptrgetType(), HealthCheckContext(nullptr, boost::none)}); } - // If health observer is disabled, then do nothing and schedule another run (health observer may - // become enabled). - if (!_config->isHealthObserverEnabled(observer->getType())) { - schedulerCb(); - return; - } - // Run asynchronous health check. Send output to the state machine. Schedule next run. - auto healthCheckFuture = observer->periodicCheck(_taskExecutor, token) - .thenRunOn(_taskExecutor) - .onCompletion([this, acceptNotOKStatus, schedulerCb]( - StatusWith status) { - ON_BLOCK_EXIT([this, schedulerCb]() { - if (!_config->periodicChecksDisabledForTests()) { - schedulerCb(); - } - }); - - if (!status.isOK()) { - return acceptNotOKStatus(status.getStatus()); - } - - accept(status.getValue()); - return status.getValue(); - }); + auto healthCheckFuture = + observer->periodicCheck(_taskExecutor, token) + .thenRunOn(_taskExecutor) + .onCompletion([this, acceptNotOKStatus, schedulerCb, observer]( + StatusWith status) { + ON_BLOCK_EXIT([this, schedulerCb, observer]() { + if (!_config->periodicChecksDisabledForTests() && + _config->isHealthObserverEnabled(observer->getType())) { + schedulerCb(); + } + }); + + if (!status.isOK()) { + return acceptNotOKStatus(status.getStatus()); + } + + accept(status.getValue()); + return status.getValue(); + }); stdx::lock_guard lock(_mutex); _healthCheckContexts.at(observer->getType()).result = -- cgit v1.2.1