summaryrefslogtreecommitdiff
path: root/src/mongo/s/hedge_options_util.cpp
diff options
context:
space:
mode:
authorCheahuychou Mao <cheahuychou.mao@mongodb.com>2020-02-04 12:17:57 -0500
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-02-05 19:54:49 +0000
commitc2e39888d052972e897b4dc8c170201e8467f964 (patch)
tree3729d9922ee55a06e7f3b47b0b4f01e1146fc8ae /src/mongo/s/hedge_options_util.cpp
parentad06b5ffbc39838e92cae0b73f51d3cf5a417116 (diff)
downloadmongo-c2e39888d052972e897b4dc8c170201e8467f964.tar.gz
SERVER-45947 Make hedging server parameters settable at runtime
Diffstat (limited to 'src/mongo/s/hedge_options_util.cpp')
-rw-r--r--src/mongo/s/hedge_options_util.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/mongo/s/hedge_options_util.cpp b/src/mongo/s/hedge_options_util.cpp
index 9301a416bcf..d4ffd133f65 100644
--- a/src/mongo/s/hedge_options_util.cpp
+++ b/src/mongo/s/hedge_options_util.cpp
@@ -39,14 +39,15 @@ boost::optional<executor::RemoteCommandRequestOnAny::HedgeOptions> extractHedgeO
OperationContext* opCtx, const BSONObj& cmdObj) {
const auto hedgingMode = ReadPreferenceSetting::get(opCtx).hedgingMode;
- if (gReadHedgingMode == kReadHedgingModeOn && hedgingMode && hedgingMode->getEnabled()) {
+ if (gReadHedgingMode.load() == ReadHedgingMode::kOn && hedgingMode &&
+ hedgingMode->getEnabled()) {
boost::optional<int> maxTimeMS;
if (auto cmdOptionMaxTimeMSField = cmdObj[QueryRequest::cmdOptionMaxTimeMS]) {
maxTimeMS = uassertStatusOK(QueryRequest::parseMaxTimeMS(cmdOptionMaxTimeMSField));
}
// Check if the operation is worth hedging.
- if (maxTimeMS && maxTimeMS > gMaxTimeMSThresholdForHedging) {
+ if (maxTimeMS && maxTimeMS > gMaxTimeMSThresholdForHedging.load()) {
return boost::none;
}
@@ -55,8 +56,8 @@ boost::optional<executor::RemoteCommandRequestOnAny::HedgeOptions> extractHedgeO
bool shouldDelayHedging = hedgingMode->getDelay();
if (shouldDelayHedging) {
- delay = maxTimeMS ? Milliseconds{gHedgingDelayPercentage * maxTimeMS.get() / 100}
- : Milliseconds{gDefaultHedgingDelayMS};
+ delay = maxTimeMS ? Milliseconds{gHedgingDelayPercentage.load() * maxTimeMS.get() / 100}
+ : Milliseconds{gDefaultHedgingDelayMS.load()};
}
return executor::RemoteCommandRequestOnAny::HedgeOptions{1, delay};