diff options
author | LaMont Nelson <lamont.nelson@mongodb.com> | 2021-12-21 20:59:26 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-12-21 21:53:18 +0000 |
commit | 1b2cdb3b2f0ead76103cc518dc0e7102a98b1f48 (patch) | |
tree | 2b39ec3fc32ff8f1bb5787e386b27c3f6fd19cc2 | |
parent | 74478fc8d09b70ef9ae031184398463cd3273692 (diff) | |
download | mongo-1b2cdb3b2f0ead76103cc518dc0e7102a98b1f48.tar.gz |
SERVER-62204 do not schedule health check if observer is not enabled
-rw-r--r-- | src/mongo/db/process_health/fault_manager.cpp | 43 |
1 files 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 89b10e32b21..d0b776ead4c 100644 --- a/src/mongo/db/process_health/fault_manager.cpp +++ b/src/mongo/db/process_health/fault_manager.cpp @@ -565,31 +565,26 @@ void FaultManager::healthCheck(HealthObserver* observer, CancellationToken token {observer->getType(), 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<HealthCheckStatus> 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<HealthCheckStatus> 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 = |