summaryrefslogtreecommitdiff
path: root/src/mongo/executor
diff options
context:
space:
mode:
authorCheahuychou Mao <cheahuychou.mao@mongodb.com>2020-03-06 02:21:55 -0500
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-03-06 23:17:56 +0000
commit3c0fa6f8e04a518f9e05b1117d3478e5c9262ea6 (patch)
tree0b3d6ef4fbb7ce1a83fb2084b60fcc0e3051c31b /src/mongo/executor
parent1e2a163839eeb90107d732eaca8f6aee3b544d55 (diff)
downloadmongo-3c0fa6f8e04a518f9e05b1117d3478e5c9262ea6.tar.gz
SERVER-46694 Make hedging_metrics_server_status.js determinstic
Diffstat (limited to 'src/mongo/executor')
-rw-r--r--src/mongo/executor/network_interface.cpp1
-rw-r--r--src/mongo/executor/network_interface.h1
-rw-r--r--src/mongo/executor/network_interface_tl.cpp31
3 files changed, 24 insertions, 9 deletions
diff --git a/src/mongo/executor/network_interface.cpp b/src/mongo/executor/network_interface.cpp
index 039053c6fa1..36cb4ee6ec4 100644
--- a/src/mongo/executor/network_interface.cpp
+++ b/src/mongo/executor/network_interface.cpp
@@ -38,6 +38,7 @@ namespace executor {
NetworkInterface::NetworkInterface() {}
NetworkInterface::~NetworkInterface() {}
+MONGO_FAIL_POINT_DEFINE(networkInterfaceConnectTargetHostsInAlphabeticalOrder);
MONGO_FAIL_POINT_DEFINE(networkInterfaceDiscardCommandsBeforeAcquireConn);
MONGO_FAIL_POINT_DEFINE(networkInterfaceHangCommandsAfterAcquireConn);
MONGO_FAIL_POINT_DEFINE(networkInterfaceAfterAcquireConn);
diff --git a/src/mongo/executor/network_interface.h b/src/mongo/executor/network_interface.h
index 63552251c20..5041697982b 100644
--- a/src/mongo/executor/network_interface.h
+++ b/src/mongo/executor/network_interface.h
@@ -42,6 +42,7 @@
namespace mongo {
namespace executor {
+extern FailPoint networkInterfaceConnectTargetHostsInAlphabeticalOrder;
extern FailPoint networkInterfaceDiscardCommandsBeforeAcquireConn;
extern FailPoint networkInterfaceHangCommandsAfterAcquireConn;
extern FailPoint networkInterfaceAfterAcquireConn;
diff --git a/src/mongo/executor/network_interface_tl.cpp b/src/mongo/executor/network_interface_tl.cpp
index 6d9acef2aa5..fbd19671d2c 100644
--- a/src/mongo/executor/network_interface_tl.cpp
+++ b/src/mongo/executor/network_interface_tl.cpp
@@ -431,6 +431,12 @@ Status NetworkInterfaceTL::startCommand(const TaskExecutor::CallbackHandle& cbHa
}
cmdState->baton = baton;
+ if (_svcCtx && cmdState->requestOnAny.hedgeOptions) {
+ auto hm = HedgingMetrics::get(_svcCtx);
+ invariant(hm);
+ hm->incrementNumTotalOperations();
+ }
+
/**
* It is important that onFinish() runs out of line. That said, we can't thenRunOn() arbitrarily
* without doing extra context switches and delaying execution. The cmdState promise can be
@@ -492,6 +498,14 @@ Status NetworkInterfaceTL::startCommand(const TaskExecutor::CallbackHandle& cbHa
invariant(cmdState->requestManager);
RequestManager* rm = cmdState->requestManager.get();
+ if (MONGO_unlikely(networkInterfaceConnectTargetHostsInAlphabeticalOrder.shouldFail())) {
+ std::sort(request.target.begin(),
+ request.target.end(),
+ [](const HostAndPort& target1, const HostAndPort& target2) {
+ return target1.toString() < target2.toString();
+ });
+ }
+
// Attempt to get a connection to every target host
for (size_t idx = 0; idx < request.target.size() && !rm->usedAllConn(); ++idx) {
auto connFuture = _pool->get(request.target[idx], request.sslMode, request.timeout);
@@ -612,9 +626,10 @@ void NetworkInterfaceTL::RequestManager::trySend(
LOGV2_DEBUG(4646300,
2,
- "Sending request {request_id} with index {idx}",
+ "Sending request {request_id} with index {idx} to {target}",
"request_id"_attr = cmdStatePtr->requestOnAny.id,
- "idx"_attr = idx);
+ "idx"_attr = idx,
+ "target"_attr = cmdStatePtr->requestOnAny.target[idx]);
auto req = getNextRequest();
if (req) {
@@ -639,17 +654,15 @@ void NetworkInterfaceTL::RequestManager::trySend(
LOGV2_DEBUG(
4647200,
2,
- "Set MaxTimeMS to {maxTimeMS} for request {request_id} with index {idx}",
+ "Set maxTimeMS to {maxTimeMS} for request {request_id} with index {idx}",
"maxTimeMS"_attr = maxTimeMS,
"request_id"_attr = cmdStatePtr->requestOnAny.id,
"idx"_attr = idx);
}
- }
- if (cmdStatePtr->interface->_svcCtx && remoteReq.hedgeOptions) {
- auto hm = HedgingMetrics::get(cmdStatePtr->interface->_svcCtx);
- invariant(hm);
- hm->incrementNumTotalOperations();
- if (req->isHedge) {
+
+ if (cmdStatePtr->interface->_svcCtx) {
+ auto hm = HedgingMetrics::get(cmdStatePtr->interface->_svcCtx);
+ invariant(hm);
hm->incrementNumTotalHedgedOperations();
}
}