diff options
author | Amirsaman Memaripour <amirsaman.memaripour@mongodb.com> | 2022-08-24 17:17:30 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-09-08 20:32:08 +0000 |
commit | 97ba88b52784d3c81a23a2994f50d16f3bf2dab0 (patch) | |
tree | 611c2cf59812aca5b87a6b454ba4a13374261dfc /src | |
parent | 4218c040fd9bf7873b765ea5d3113f718c44e9eb (diff) | |
download | mongo-97ba88b52784d3c81a23a2994f50d16f3bf2dab0.tar.gz |
SERVER-67465 Ensure network timeouts do not fail hedged operations
(cherry picked from commit 1744ab66eafba2dcc6dd96d7fa0d0d77eeae35d8)
Diffstat (limited to 'src')
-rw-r--r-- | src/mongo/executor/network_interface_tl.cpp | 39 |
1 files changed, 23 insertions, 16 deletions
diff --git a/src/mongo/executor/network_interface_tl.cpp b/src/mongo/executor/network_interface_tl.cpp index 9a2695534dc..734ad7efb15 100644 --- a/src/mongo/executor/network_interface_tl.cpp +++ b/src/mongo/executor/network_interface_tl.cpp @@ -49,7 +49,21 @@ namespace executor { namespace { static inline const std::string kMaxTimeMSOpOnlyField = "maxTimeMSOpOnly"; -} // unnamed namespace + +/** + * We ignore a subset of errors that may occur while running hedged operations (e.g., maxTimeMS + * expiration), as the operation may safely succeed despite their failure. For example, a network + * timeout error indicates the remote host experienced a timeout while running a remote-command as + * part of executing the hedged operation. This is by no means an indication that the operation has + * failed, as other hedged operations may still succeed. + * TODO SERVER-68704 will include other error categories that are safe to ignore. + */ +bool skipHedgeResult(const Status& status) { + return status == ErrorCodes::MaxTimeMSExpired || status == ErrorCodes::StaleDbVersion || + ErrorCodes::isNetworkTimeoutError(status) || ErrorCodes::isStaleShardVersionError(status); +} + +} // namespace /** * SynchronizedCounters is synchronized bucket of event counts for commands @@ -822,21 +836,14 @@ void NetworkInterfaceTL::RequestState::resolve(Future<RemoteCommandResponse> fut returnConnection(status); 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 (isHedge && skipHedgeResult(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()) { |