diff options
author | Andrew Witten <andrew.witten@mongodb.com> | 2021-11-05 13:31:39 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-11-05 14:16:41 +0000 |
commit | 116e5b8e47a90bbc5a892bd071b1b23295d13c58 (patch) | |
tree | c6b4c6c28900b1258a2ad3f5b42cc570849093e3 | |
parent | c3b6bdf71ed1e39e3cfdc0f6738b085f352b333f (diff) | |
download | mongo-116e5b8e47a90bbc5a892bd071b1b23295d13c58.tar.gz |
SERVER-61071 Removes all instances of `HealthObserverIntensity`
8 files changed, 14 insertions, 42 deletions
diff --git a/src/mongo/db/process_health/fault_manager.cpp b/src/mongo/db/process_health/fault_manager.cpp index c237e27773b..86d7b4406bc 100644 --- a/src/mongo/db/process_health/fault_manager.cpp +++ b/src/mongo/db/process_health/fault_manager.cpp @@ -229,7 +229,10 @@ void FaultManager::healthCheck() { // Start checks outside of lock. auto token = _managerShuttingDownCancellationSource.token(); for (auto observer : observers) { - observer->periodicCheck(*this, _taskExecutor, token); + // TODO: fix bug where health observer is turned off which in transient fault state + if (_config->getHealthObserverIntensity(observer->getType()) != + HealthObserverIntensityEnum::kOff) + observer->periodicCheck(*this, _taskExecutor, token); } // Garbage collect all resolved fault facets. diff --git a/src/mongo/db/process_health/fault_manager_config.h b/src/mongo/db/process_health/fault_manager_config.h index 2c64565018f..2cf26e2f7cf 100644 --- a/src/mongo/db/process_health/fault_manager_config.h +++ b/src/mongo/db/process_health/fault_manager_config.h @@ -60,20 +60,6 @@ StringBuilder& operator<<(StringBuilder& s, const FaultState& state); std::ostream& operator<<(std::ostream& os, const FaultState& state); -enum class HealthObserverIntensity { - // Health checks enabled and the health observer can cause the process to transition to the - // ActiveFault state. - kCritical = 0, - - // Health checks enabled, but the health observer cannot cause the process to transition to the - // ActiveFault state. - kNonCritical, - - // Health checks not enabled. - kOff -}; - - /** * Types of health observers available. */ @@ -99,6 +85,10 @@ public: } } + bool isHealthObserverEnabled(FaultFacetType type) { + return getHealthObserverIntensity(type) != HealthObserverIntensityEnum::kOff; + } + Milliseconds getActiveFaultDuration() const { return kActiveFaultDuration; } diff --git a/src/mongo/db/process_health/health_observer.h b/src/mongo/db/process_health/health_observer.h index 40c9d379db7..319876e4017 100644 --- a/src/mongo/db/process_health/health_observer.h +++ b/src/mongo/db/process_health/health_observer.h @@ -41,8 +41,6 @@ namespace process_health { * Liveness data and stats. */ struct HealthObserverLivenessStats { - // True if this observer is enabled. - bool isEnabled = false; // true is this observer is currently running a health check. bool currentlyRunningHealthCheck = false; // When the last or current check started, depending if currently @@ -89,11 +87,6 @@ public: std::shared_ptr<executor::TaskExecutor> taskExecutor, CancellationToken token) = 0; - /** - * @return HealthObserverIntensity - */ - virtual HealthObserverIntensity getIntensity() const = 0; - virtual HealthObserverLivenessStats getStats() const = 0; }; diff --git a/src/mongo/db/process_health/health_observer_base.cpp b/src/mongo/db/process_health/health_observer_base.cpp index d3f6dd03c30..04f38f51daa 100644 --- a/src/mongo/db/process_health/health_observer_base.cpp +++ b/src/mongo/db/process_health/health_observer_base.cpp @@ -42,11 +42,8 @@ HealthObserverBase::HealthObserverBase(ServiceContext* svcCtx) : _svcCtx(svcCtx) void HealthObserverBase::periodicCheck(FaultFacetsContainerFactory& factory, std::shared_ptr<executor::TaskExecutor> taskExecutor, CancellationToken token) { - // TODO(SERVER-59368): fix this for runtime options support. - if (getIntensity() == HealthObserverIntensity::kOff) { - return; - } + // If we have reached here, the intensity of this health observer must not be off { auto lk = stdx::lock_guard(_mutex); if (_currentlyRunningHealthCheck) { @@ -93,10 +90,6 @@ void HealthObserverBase::periodicCheck(FaultFacetsContainerFactory& factory, }); } -HealthObserverIntensity HealthObserverBase::getIntensity() const { - return _intensity; -} - HealthCheckStatus HealthObserverBase::makeHealthyStatus() const { return HealthCheckStatus(getType()); } @@ -124,7 +117,6 @@ HealthObserverLivenessStats HealthObserverBase::getStats() const { HealthObserverLivenessStats HealthObserverBase::getStatsLocked(WithLock) const { HealthObserverLivenessStats stats; - stats.isEnabled = _intensity != HealthObserverIntensity::kOff; stats.currentlyRunningHealthCheck = _currentlyRunningHealthCheck; stats.lastTimeCheckStarted = _lastTimeTheCheckWasRun; stats.lastTimeCheckCompleted = _lastTimeCheckCompleted; diff --git a/src/mongo/db/process_health/health_observer_base.h b/src/mongo/db/process_health/health_observer_base.h index 382f237c6fa..070e145d38a 100644 --- a/src/mongo/db/process_health/health_observer_base.h +++ b/src/mongo/db/process_health/health_observer_base.h @@ -87,8 +87,6 @@ protected: virtual Future<HealthCheckStatus> periodicCheckImpl( PeriodicHealthCheckContext&& periodicCheckContext) = 0; - HealthObserverIntensity getIntensity() const override; - // Helper method to create a status without errors. HealthCheckStatus makeHealthyStatus() const; @@ -101,8 +99,7 @@ protected: mutable Mutex _mutex = MONGO_MAKE_LATCH(HierarchicalAcquisitionLevel(1), "HealthObserverBase::_mutex"); - // TODO: remove this field, should be done in config. - HealthObserverIntensity _intensity = HealthObserverIntensity::kNonCritical; + // Indicates if there any check running to prevent running checks concurrently. bool _currentlyRunningHealthCheck = false; // Enforces the safety interval. diff --git a/src/mongo/db/process_health/health_observer_mock.h b/src/mongo/db/process_health/health_observer_mock.h index 17516f13c98..1270af28cc3 100644 --- a/src/mongo/db/process_health/health_observer_mock.h +++ b/src/mongo/db/process_health/health_observer_mock.h @@ -74,10 +74,6 @@ protected: return std::move(completionPf.future); } - HealthObserverIntensity getIntensity() const override { - return HealthObserverIntensity::kNonCritical; - } - private: const FaultFacetType _mockType; std::function<double()> _getSeverityCallback; diff --git a/src/mongo/db/process_health/health_observer_test.cpp b/src/mongo/db/process_health/health_observer_test.cpp index f75dfc5eb14..f8ea21439f4 100644 --- a/src/mongo/db/process_health/health_observer_test.cpp +++ b/src/mongo/db/process_health/health_observer_test.cpp @@ -227,7 +227,7 @@ TEST_F(FaultManagerTest, Stats) { auto observer = manager().getHealthObserversTest()[0]; auto stats = observer->getStats(); - ASSERT_TRUE(stats.isEnabled); + ASSERT_TRUE(manager().getConfig().isHealthObserverEnabled(observer->getType())); ASSERT_FALSE(stats.currentlyRunningHealthCheck); ASSERT_TRUE(stats.lastTimeCheckStarted >= clockSource().now()); ASSERT_TRUE(stats.lastTimeCheckCompleted >= stats.lastTimeCheckStarted); diff --git a/src/mongo/db/process_health/progress_monitor.cpp b/src/mongo/db/process_health/progress_monitor.cpp index 75fdd4f93c1..7c2fd4fe221 100644 --- a/src/mongo/db/process_health/progress_monitor.cpp +++ b/src/mongo/db/process_health/progress_monitor.cpp @@ -65,7 +65,7 @@ void ProgressMonitor::progressMonitorCheck(std::function<void(std::string cause) // Check the liveness of every health observer. for (auto observer : observers) { const auto stats = observer->getStats(); - if (!stats.isEnabled) { + if (!_faultManager->getConfig().isHealthObserverEnabled(observer->getType())) { continue; } @@ -96,7 +96,8 @@ void ProgressMonitor::progressMonitorCheck(std::function<void(std::string cause) sleepFor(_faultManager->getConfig().getPeriodicHealthCheckInterval() * 2); for (auto observer : secondPass) { const auto stats = observer->getStats(); - if (stats.isEnabled && !stats.currentlyRunningHealthCheck && + if (!_faultManager->getConfig().isHealthObserverEnabled(observer->getType()) && + !stats.currentlyRunningHealthCheck && now - stats.lastTimeCheckStarted > _faultManager->getConfig().getPeriodicLivenessDeadline() * 2) { // Crash because this health checker was never started. |