summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaume Moragues <jaume.moragues@mongodb.com>2020-12-16 07:59:00 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-09-08 20:32:08 +0000
commit4218c040fd9bf7873b765ea5d3113f718c44e9eb (patch)
tree4f59abf225108491e37aa17b3d529e15a8c729d9
parent95f7351385d89754877e239bfbe59acf644ba883 (diff)
downloadmongo-4218c040fd9bf7873b765ea5d3113f718c44e9eb.tar.gz
SERVER-52676 Hedged reads should ignore stale errors
(cherry picked from commit a62abb0614bbcff329a89ba76fe42d2d3d4e2d3c)
-rw-r--r--src/mongo/executor/network_interface_tl.cpp27
1 files changed, 16 insertions, 11 deletions
diff --git a/src/mongo/executor/network_interface_tl.cpp b/src/mongo/executor/network_interface_tl.cpp
index b26033ffa86..9a2695534dc 100644
--- a/src/mongo/executor/network_interface_tl.cpp
+++ b/src/mongo/executor/network_interface_tl.cpp
@@ -821,17 +821,22 @@ void NetworkInterfaceTL::RequestState::resolve(Future<RemoteCommandResponse> fut
returnConnection(status);
- auto commandStatus = getStatusFromCommandResult(response.data);
- // Ignore maxTimeMS expiration errors for hedged reads without triggering the finish
- // line.
- if (isHedge && commandStatus == ErrorCodes::MaxTimeMSExpired) {
- LOGV2_DEBUG(4660701,
- 2,
- "Hedged request returned status",
- "requestId"_attr = request->id,
- "target"_attr = request->target,
- "status"_attr = commandStatus);
- return;
+ const auto commandStatus = getStatusFromCommandResult(response.data);
+ if (isHedge) {
+ // Ignore maxTimeMS expiration, StaleDbVersion or any error belonging to
+ // StaleShardVersionError
+ // error category for hedged reads without triggering the finish line.
+ if (commandStatus == ErrorCodes::MaxTimeMSExpired ||
+ commandStatus == ErrorCodes::StaleDbVersion ||
+ ErrorCodes::isStaleShardVersionError(commandStatus)) {
+ LOGV2_DEBUG(4660701,
+ 2,
+ "Hedged request returned status",
+ "requestId"_attr = request->id,
+ "target"_attr = request->target,
+ "status"_attr = commandStatus);
+ return;
+ }
}
if (!cmdState->finishLine.arriveStrongly()) {