diff options
author | Kshitij Gupta <kshitij.gupta@mongodb.com> | 2021-12-14 09:50:49 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-12-16 22:58:18 +0000 |
commit | fa202b3594be0389f1fcd7e93e8f6d11ccb6e933 (patch) | |
tree | 031cfe3076119827c9657c162c7e0742c2c46233 /src/mongo/db/process_health/health_observer_base.cpp | |
parent | 00b7518783c6a576c0996fc27f0bb85f13c78fc3 (diff) | |
download | mongo-fa202b3594be0389f1fcd7e93e8f6d11ccb6e933.tar.gz |
SERVER-61930: Individual health observers should return an error if a
timeout period elapses when doing a single health check.
Diffstat (limited to 'src/mongo/db/process_health/health_observer_base.cpp')
-rw-r--r-- | src/mongo/db/process_health/health_observer_base.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/mongo/db/process_health/health_observer_base.cpp b/src/mongo/db/process_health/health_observer_base.cpp index 25556c80f95..47831d5fa56 100644 --- a/src/mongo/db/process_health/health_observer_base.cpp +++ b/src/mongo/db/process_health/health_observer_base.cpp @@ -31,6 +31,7 @@ #include "mongo/db/process_health/health_observer_base.h" +#include "mongo/db/process_health/deadline_future.h" #include "mongo/db/service_context.h" #include "mongo/logv2/log.h" @@ -48,17 +49,17 @@ SharedSemiFuture<HealthCheckStatus> HealthObserverBase::periodicCheck( { auto lk = stdx::lock_guard(_mutex); if (_currentlyRunningHealthCheck) { - return _periodicCheckPromise->getFuture(); + return _deadlineFuture->get(); } LOGV2_DEBUG(6007902, 2, "Start periodic health check", "observerType"_attr = getType()); const auto now = _svcCtx->getPreciseClockSource()->now(); _lastTimeTheCheckWasRun = now; _currentlyRunningHealthCheck = true; - _periodicCheckPromise = std::make_unique<SharedPromise<HealthCheckStatus>>(); } - _periodicCheckPromise->setFrom( + _deadlineFuture = std::make_unique<DeadlineFuture<HealthCheckStatus>>( + taskExecutor, periodicCheckImpl({token, taskExecutor}) .onCompletion([this](StatusWith<HealthCheckStatus> status) { if (!status.isOK()) { @@ -77,9 +78,10 @@ SharedSemiFuture<HealthCheckStatus> HealthObserverBase::periodicCheck( _currentlyRunningHealthCheck = false; _lastTimeCheckCompleted = now; return status; - })); + }), + getObserverTimeout()); - return _periodicCheckPromise->getFuture(); + return _deadlineFuture->get(); } HealthCheckStatus HealthObserverBase::makeHealthyStatus() const { |