diff options
author | Andrew Shuvalov <andrew.shuvalov@mongodb.com> | 2021-07-14 14:10:05 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-07-14 14:32:46 +0000 |
commit | 2fec2bd8bba95640b8606686a9e1bb44f1ec29e5 (patch) | |
tree | 656e27e3274eeb5f2e3308dcb9e40599cd474025 /src/mongo/client | |
parent | 1f0278ec2362f0796929cb6a0fa9c74072455831 (diff) | |
download | mongo-2fec2bd8bba95640b8606686a9e1bb44f1ec29e5.tar.gz |
SERVER-56489: New pass-through test with hello server-side delays
Diffstat (limited to 'src/mongo/client')
-rw-r--r-- | src/mongo/client/scanning_replica_set_monitor.cpp | 20 | ||||
-rw-r--r-- | src/mongo/client/scanning_replica_set_monitor.h | 16 | ||||
-rw-r--r-- | src/mongo/client/server_discovery_monitor.cpp | 4 |
3 files changed, 27 insertions, 13 deletions
diff --git a/src/mongo/client/scanning_replica_set_monitor.cpp b/src/mongo/client/scanning_replica_set_monitor.cpp index afe643a8d14..0902abd94e0 100644 --- a/src/mongo/client/scanning_replica_set_monitor.cpp +++ b/src/mongo/client/scanning_replica_set_monitor.cpp @@ -246,7 +246,7 @@ void ScanningReplicaSetMonitor::SetState::rescheduleRefresh(SchedulingStrategy s return; } - Milliseconds period = refreshPeriod; + Milliseconds period = _getRefreshPeriod(); // Supports fail injection. if (isExpedited) { period = std::min<Milliseconds>(period, kExpeditedRefreshPeriod); } @@ -495,14 +495,20 @@ bool ScanningReplicaSetMonitor::isKnownToHaveGoodPrimary() const { return false; } -Seconds ScanningReplicaSetMonitor::getDefaultRefreshPeriod() { - Seconds r = kDefaultRefreshPeriod; +Seconds ScanningReplicaSetMonitor::_getRefreshPeriod() { + boost::optional<Seconds> failInjected = _getFailInjectedRefreshPeriod(); + return failInjected ? *failInjected : kDefaultRefreshPeriod; +} + +boost::optional<Seconds> ScanningReplicaSetMonitor::_getFailInjectedRefreshPeriod() { + boost::optional<Seconds> result; static constexpr auto kPeriodField = "period"_sd; globalFailPointRegistry() .find("modifyReplicaSetMonitorDefaultRefreshPeriod") - ->executeIf([&r](const BSONObj& data) { r = Seconds{data.getIntField(kPeriodField)}; }, - [](const BSONObj& data) { return data.hasField(kPeriodField); }); - return r; + ->executeIf( + [&result](const BSONObj& data) { result = Seconds{data.getIntField(kPeriodField)}; }, + [](const BSONObj& data) { return data.hasField(kPeriodField); }); + return result; } void ScanningReplicaSetMonitor::runScanForMockReplicaSet() { @@ -1138,7 +1144,7 @@ SetState::SetState(const MongoURI& uri, seedNodes(setUri.getServers().begin(), setUri.getServers().end()), latencyThresholdMicros(serverGlobalParams.defaultLocalThresholdMillis * int64_t(1000)), rand(std::random_device()()), - refreshPeriod(getDefaultRefreshPeriod()) { + refreshPeriod(_getRefreshPeriod()) { uassert(13642, "Replica set seed list can't be empty", !seedNodes.empty()); if (name.empty()) diff --git a/src/mongo/client/scanning_replica_set_monitor.h b/src/mongo/client/scanning_replica_set_monitor.h index 094db3e3300..85295e099f1 100644 --- a/src/mongo/client/scanning_replica_set_monitor.h +++ b/src/mongo/client/scanning_replica_set_monitor.h @@ -123,11 +123,6 @@ public: bool isKnownToHaveGoodPrimary() const override; - /** - * Returns the refresh period that is given to all new SetStates. - */ - static Seconds getDefaultRefreshPeriod(); - // // internal types (defined in scanning_replica_set_monitor_internal.h) // @@ -160,12 +155,23 @@ private: const ReadPreferenceSetting& readPref, Milliseconds maxWait, const std::vector<HostAndPort>& excludedHosts); + /** * If no scan is in-progress, this function is responsible for setting up a new scan. Otherwise, * does nothing. */ static void _ensureScanInProgress(const SetStatePtr&); + /** + * Returns the refresh period that is given to all new SetStates. + */ + static Seconds _getRefreshPeriod(); + + /** + * Returns fail injected refresh period, if fail point is set. + */ + static boost::optional<Seconds> _getFailInjectedRefreshPeriod(); + const SetStatePtr _state; }; diff --git a/src/mongo/client/server_discovery_monitor.cpp b/src/mongo/client/server_discovery_monitor.cpp index e7bfe11c8e0..6785aed62bb 100644 --- a/src/mongo/client/server_discovery_monitor.cpp +++ b/src/mongo/client/server_discovery_monitor.cpp @@ -437,7 +437,9 @@ Milliseconds SingleServerDiscoveryMonitor::_currentRefreshPeriod(WithLock, if (scheduleImmediately) return Milliseconds(0); - return (_isExpedited) ? sdam::SdamConfiguration::kMinHeartbeatFrequency : _heartbeatFrequency; + // The _overrideRefreshPeriod() supports fail injection. + return (_isExpedited) ? sdam::SdamConfiguration::kMinHeartbeatFrequency + : _overrideRefreshPeriod(_heartbeatFrequency); } void SingleServerDiscoveryMonitor::disableExpeditedChecking() { |