summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaMont Nelson <lamont.nelson@mongodb.com>2021-12-21 20:59:26 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-12-29 01:30:33 +0000
commit248557de9e06097d5c56f691f919c09f7a58e852 (patch)
treefc973a6251c85c2751c149d539de697a464ac0d1
parent25b41c59fd56ccd2cc83f02801a622b768e6d692 (diff)
downloadmongo-248557de9e06097d5c56f691f919c09f7a58e852.tar.gz
SERVER-62204 do not schedule health check if observer is not enabled
(cherry picked from commit 1b2cdb3b2f0ead76103cc518dc0e7102a98b1f48)
-rw-r--r--src/mongo/db/process_health/fault_manager.cpp43
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 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_ptr<AtomicW
{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 =