summaryrefslogtreecommitdiff
path: root/src/mongo/db/query
diff options
context:
space:
mode:
authorVarun Ravichandran <varun.ravichandran@mongodb.com>2022-06-23 05:42:07 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-06-27 17:43:30 +0000
commit3fd2a61085f8c72a13d1bc00ad95c460c69eb8a8 (patch)
tree32768cb62c474dd96f0f94799bc2ada4775b4dca /src/mongo/db/query
parentab5428c183b85d97c8c7016de4aefa34d055adcb (diff)
downloadmongo-3fd2a61085f8c72a13d1bc00ad95c460c69eb8a8.tar.gz
SERVER-43155 Queries which exceed `maxTimeMS` may return `NetworkInterfaceExceededTimeLimit`
After careful evaluation and research the service-arch team settled into adding a new argument into connection pool's interface allowing their users to specify a custom timeout status in case the pool fails to deliver a connection within a specified time. This timeout status now competes with `NetworkInterfaceExceededTimeLimit` which is now returned either when the Connection Pool Controller is rather used to compute the timeout or when no custom timeout status code is specified. This commit also: - Refactors portions of `ConnectionPoolTest` to reflect changes in the API. - Adds `jstests/sharding/max_time_ms_connection_pool.js` integration test to ensure different timeouts return different statuses. - Fixes small glitch in `jstests/core/tnxs/many_txns.js` where `NetworkInterfaceExceededTimeLimit` might be validly returned under rare resource intense conditions and fail the test, reported as BF-20554.
Diffstat (limited to 'src/mongo/db/query')
-rw-r--r--src/mongo/db/query/max_time_ms_parser.cpp17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/mongo/db/query/max_time_ms_parser.cpp b/src/mongo/db/query/max_time_ms_parser.cpp
index 054b2b76ead..38cf4a3d6d7 100644
--- a/src/mongo/db/query/max_time_ms_parser.cpp
+++ b/src/mongo/db/query/max_time_ms_parser.cpp
@@ -29,6 +29,8 @@
#include "mongo/db/query/max_time_ms_parser.h"
+#include <fmt/format.h>
+
#include "mongo/bson/bsonobjbuilder.h"
#include "mongo/util/assert_util.h"
@@ -45,13 +47,14 @@ StatusWith<int> parseMaxTimeMS(BSONElement maxTimeMSElt) {
const long long maxVal = maxTimeMSElt.fieldNameStringData() == kMaxTimeMSOpOnlyField
? (long long)(INT_MAX) + kMaxTimeMSOpOnlyMaxPadding
: INT_MAX;
- if (maxTimeMSLongLong < 0 || maxTimeMSLongLong > maxVal) {
- return StatusWith<int>(ErrorCodes::BadValue,
- (StringBuilder()
- << maxTimeMSLongLong << " value for "
- << maxTimeMSElt.fieldNameStringData() << " is out of range")
- .str());
- }
+
+ using namespace fmt::literals;
+
+ if (maxTimeMSLongLong < 0 || maxTimeMSLongLong > maxVal)
+ return Status(ErrorCodes::BadValue,
+ "{} value for {} is out of range [{}, {}]"_format(
+ maxTimeMSLongLong, maxTimeMSElt.fieldNameStringData(), 0, maxVal));
+
double maxTimeMSDouble = maxTimeMSElt.numberDouble();
if (maxTimeMSElt.type() == mongo::NumberDouble && floor(maxTimeMSDouble) != maxTimeMSDouble) {
return StatusWith<int>(