summaryrefslogtreecommitdiff
path: root/src/mongo/db/repl/replication_info.cpp
diff options
context:
space:
mode:
authorHaley Connelly <haley.connelly@10gen.com>2019-11-22 16:50:50 +0000
committerevergreen <evergreen@mongodb.com>2019-11-22 16:50:50 +0000
commitc72849fb005cfcba272eb53b6024d5fd31c3ec9c (patch)
treed51da71f11fab1b618aa661590d09a9a7717c0ad /src/mongo/db/repl/replication_info.cpp
parente023b4c6e2bc3a460b420a2f75fcf13dd93b07b8 (diff)
downloadmongo-c72849fb005cfcba272eb53b6024d5fd31c3ec9c.tar.gz
SERVER-44508 Add maxAwaitTimeMS and topologyVersion to isMaster Command
Diffstat (limited to 'src/mongo/db/repl/replication_info.cpp')
-rw-r--r--src/mongo/db/repl/replication_info.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/mongo/db/repl/replication_info.cpp b/src/mongo/db/repl/replication_info.cpp
index c21394e0145..ad6d066fff4 100644
--- a/src/mongo/db/repl/replication_info.cpp
+++ b/src/mongo/db/repl/replication_info.cpp
@@ -33,6 +33,7 @@
#include <list>
#include <vector>
+#include "mongo/bson/util/bson_extract.h"
#include "mongo/client/connpool.h"
#include "mongo/client/dbclient_connection.h"
#include "mongo/db/auth/sasl_mechanism_registry.h"
@@ -291,6 +292,30 @@ public:
SplitHorizon::setParameters(opCtx->getClient(), std::move(sniName));
}
+ // If a client is following the awaitable isMaster protocol, maxAwaitTimeMS should be
+ // present if and only if topologyVersion is present in the request.
+ auto topologyVersionElement = cmdObj["topologyVersion"];
+ auto maxAwaitTimeMSField = cmdObj["maxAwaitTimeMS"];
+ if (topologyVersionElement && maxAwaitTimeMSField) {
+ auto topologyVersion = TopologyVersion::parse(IDLParserErrorContext("TopologyVersion"),
+ topologyVersionElement.Obj());
+ uassert(31372,
+ "topologyVersion must have a non-negative counter",
+ topologyVersion.getCounter() >= 0);
+
+ long long maxAwaitTimeMSValue;
+ uassertStatusOK(
+ bsonExtractIntegerField(cmdObj, "maxAwaitTimeMS", &maxAwaitTimeMSValue));
+ uassert(
+ 31373, "maxAwaitTimeMS must be a non-negative integer", maxAwaitTimeMSValue >= 0);
+ } else {
+ uassert(31368,
+ (topologyVersionElement
+ ? "A request with a 'topologyVersion' must include 'maxAwaitTimeMS'"
+ : "A request with 'maxAwaitTimeMS' must include a 'topologyVersion'"),
+ !topologyVersionElement && !maxAwaitTimeMSField);
+ }
+
// Parse the optional 'internalClient' field. This is provided by incoming connections from
// mongod and mongos.
auto internalClientElement = cmdObj["internalClient"];