summaryrefslogtreecommitdiff
path: root/src/mongo/executor
diff options
context:
space:
mode:
authorCheahuychou Mao <cheahuychou.mao@mongodb.com>2020-01-21 11:32:46 -0500
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-01-29 03:30:29 +0000
commit367f47f7f19a6344039a15e3d0748508ad9c6c2c (patch)
treea9daabfa3c33534496c55bd4d20b87f131c0ba96 /src/mongo/executor
parent5fd95451f78ad667eccca8d4934873529a35e746 (diff)
downloadmongo-367f47f7f19a6344039a15e3d0748508ad9c6c2c.tar.gz
SERVER-45449 Write a function to compute the desired latency for a staggered hedged read
create mode 100644 jstests/sharding/hedged_reads_server_parameters.js rename src/mongo/s/{warmup_server_parameters.cpp => hedge_options_util.cpp} (52%) rename src/mongo/s/{warmup_server_parameters.h => hedge_options_util.h} (74%) create mode 100644 src/mongo/s/hedge_options_util_test.cpp create mode 100644 src/mongo/s/mongos_server_parameters.idl
Diffstat (limited to 'src/mongo/executor')
-rw-r--r--src/mongo/executor/remote_command_request.cpp37
-rw-r--r--src/mongo/executor/remote_command_request.h40
2 files changed, 69 insertions, 8 deletions
diff --git a/src/mongo/executor/remote_command_request.cpp b/src/mongo/executor/remote_command_request.cpp
index b8ffb8486e5..be119d7d69b 100644
--- a/src/mongo/executor/remote_command_request.cpp
+++ b/src/mongo/executor/remote_command_request.cpp
@@ -59,8 +59,13 @@ RemoteCommandRequestBase::RemoteCommandRequestBase(RequestId requestId,
const BSONObj& theCmdObj,
const BSONObj& metadataObj,
OperationContext* opCtx,
- Milliseconds timeoutMillis)
- : id(requestId), dbname(theDbName), metadata(metadataObj), opCtx(opCtx) {
+ Milliseconds timeoutMillis,
+ boost::optional<HedgeOptions> hedgeOptions)
+ : id(requestId),
+ dbname(theDbName),
+ metadata(metadataObj),
+ opCtx(opCtx),
+ hedgeOptions(hedgeOptions) {
// If there is a comment associated with the current operation, append it to the command that we
// are about to dispatch to the shards.
//
@@ -91,8 +96,10 @@ RemoteCommandRequestImpl<T>::RemoteCommandRequestImpl(RequestId requestId,
const BSONObj& theCmdObj,
const BSONObj& metadataObj,
OperationContext* opCtx,
- Milliseconds timeoutMillis)
- : RemoteCommandRequestBase(requestId, theDbName, theCmdObj, metadataObj, opCtx, timeoutMillis),
+ Milliseconds timeoutMillis,
+ boost::optional<HedgeOptions> hedgeOptions)
+ : RemoteCommandRequestBase(
+ requestId, theDbName, theCmdObj, metadataObj, opCtx, timeoutMillis, hedgeOptions),
target(theTarget) {
if constexpr (std::is_same_v<T, std::vector<HostAndPort>>) {
invariant(!theTarget.empty());
@@ -100,19 +107,32 @@ RemoteCommandRequestImpl<T>::RemoteCommandRequestImpl(RequestId requestId,
}
template <typename T>
-RemoteCommandRequestImpl<T>::RemoteCommandRequestImpl(const T& theTarget,
+RemoteCommandRequestImpl<T>::RemoteCommandRequestImpl(RequestId requestId,
+ const T& theTarget,
const std::string& theDbName,
const BSONObj& theCmdObj,
const BSONObj& metadataObj,
OperationContext* opCtx,
Milliseconds timeoutMillis)
+ : RemoteCommandRequestImpl(
+ requestId, theTarget, theDbName, theCmdObj, metadataObj, opCtx, timeoutMillis, {}) {}
+
+template <typename T>
+RemoteCommandRequestImpl<T>::RemoteCommandRequestImpl(const T& theTarget,
+ const std::string& theDbName,
+ const BSONObj& theCmdObj,
+ const BSONObj& metadataObj,
+ OperationContext* opCtx,
+ Milliseconds timeoutMillis,
+ boost::optional<HedgeOptions> hedgeOptions)
: RemoteCommandRequestImpl(requestIdCounter.addAndFetch(1),
theTarget,
theDbName,
theCmdObj,
metadataObj,
opCtx,
- timeoutMillis) {}
+ timeoutMillis,
+ hedgeOptions) {}
template <typename T>
std::string RemoteCommandRequestImpl<T>::toString() const {
@@ -129,6 +149,11 @@ std::string RemoteCommandRequestImpl<T>::toString() const {
out << " expDate:" << expirationDate.toString();
}
+ if (hedgeOptions) {
+ out << " hedgeOptions.count: " << hedgeOptions->count;
+ out << " hedgeOptions.delay: " << hedgeOptions->delay;
+ }
+
out << " cmd:" << cmdObj.toString();
return out;
}
diff --git a/src/mongo/executor/remote_command_request.h b/src/mongo/executor/remote_command_request.h
index b776a14eafa..ab1cf4b3a34 100644
--- a/src/mongo/executor/remote_command_request.h
+++ b/src/mongo/executor/remote_command_request.h
@@ -43,6 +43,11 @@ namespace mongo {
namespace executor {
struct RemoteCommandRequestBase {
+ struct HedgeOptions {
+ size_t count;
+ Milliseconds delay;
+ };
+
// Indicates that there is no timeout for the request to complete
static constexpr Milliseconds kNoTimeout{-1};
@@ -58,7 +63,8 @@ struct RemoteCommandRequestBase {
const BSONObj& theCmdObj,
const BSONObj& metadataObj,
OperationContext* opCtx,
- Milliseconds timeoutMillis);
+ Milliseconds timeoutMillis,
+ boost::optional<HedgeOptions> hedgeOptions);
// Internal id of this request. Not interpreted and used for tracing purposes only.
RequestId id;
@@ -76,6 +82,8 @@ struct RemoteCommandRequestBase {
// metadata attachment (i.e., replication).
OperationContext* opCtx{nullptr};
+ boost::optional<HedgeOptions> hedgeOptions;
+
Milliseconds timeout = kNoTimeout;
// Deadline by when the request must be completed
@@ -112,6 +120,15 @@ struct RemoteCommandRequestImpl : RemoteCommandRequestBase {
const BSONObj& theCmdObj,
const BSONObj& metadataObj,
OperationContext* opCtx,
+ Milliseconds timeoutMillis,
+ boost::optional<HedgeOptions> hedgeOptions);
+
+ RemoteCommandRequestImpl(RequestId requestId,
+ const Target& theTarget,
+ const std::string& theDbName,
+ const BSONObj& theCmdObj,
+ const BSONObj& metadataObj,
+ OperationContext* opCtx,
Milliseconds timeoutMillis);
RemoteCommandRequestImpl(const Target& theTarget,
@@ -119,7 +136,26 @@ struct RemoteCommandRequestImpl : RemoteCommandRequestBase {
const BSONObj& theCmdObj,
const BSONObj& metadataObj,
OperationContext* opCtx,
- Milliseconds timeoutMillis = kNoTimeout);
+ Milliseconds timeoutMillis,
+ boost::optional<HedgeOptions> hedgeOptions);
+
+ RemoteCommandRequestImpl(const Target& theTarget,
+ const std::string& theDbName,
+ const BSONObj& theCmdObj,
+ const BSONObj& metadataObj,
+ OperationContext* opCtx,
+ Milliseconds timeoutMillis = kNoTimeout)
+ : RemoteCommandRequestImpl(
+ theTarget, theDbName, theCmdObj, metadataObj, opCtx, timeoutMillis, boost::none) {}
+
+ RemoteCommandRequestImpl(const Target& theTarget,
+ const std::string& theDbName,
+ const BSONObj& theCmdObj,
+ const BSONObj& metadataObj,
+ OperationContext* opCtx,
+ boost::optional<HedgeOptions> hedgeOptions)
+ : RemoteCommandRequestImpl(
+ theTarget, theDbName, theCmdObj, metadataObj, opCtx, kNoTimeout, hedgeOptions) {}
RemoteCommandRequestImpl(const Target& theTarget,
const std::string& theDbName,