diff options
author | A. Jesse Jiryu Davis <jesse@mongodb.com> | 2021-05-12 14:03:05 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-05-12 18:57:08 +0000 |
commit | 270908b05b9f98709a85faffe624aaf175707ecc (patch) | |
tree | 0dfd0bac16fd2dd09c0348a5a820f5bfb7b7f459 /src/mongo/client | |
parent | 265ba00b96161463bc2a6d8640098d3ac4e4b70a (diff) | |
download | mongo-270908b05b9f98709a85faffe624aaf175707ecc.tar.gz |
SERVER-55596 Remove isMaster from API Version 1
Diffstat (limited to 'src/mongo/client')
-rw-r--r-- | src/mongo/client/dbclient_base.cpp | 5 | ||||
-rw-r--r-- | src/mongo/client/dbclient_connection.cpp | 2 | ||||
-rw-r--r-- | src/mongo/client/scanning_replica_set_monitor.cpp | 2 |
3 files changed, 5 insertions, 4 deletions
diff --git a/src/mongo/client/dbclient_base.cpp b/src/mongo/client/dbclient_base.cpp index b6944cc64c4..8af0924768d 100644 --- a/src/mongo/client/dbclient_base.cpp +++ b/src/mongo/client/dbclient_base.cpp @@ -580,7 +580,7 @@ void DBClientBase::logout(const string& dbname, BSONObj& info) { bool DBClientBase::isPrimary(bool& isPrimary, BSONObj* info) { BSONObjBuilder bob; - bob.append("ismaster", 1); + bob.append(_apiParameters.getVersion() ? "hello" : "ismaster", 1); if (auto wireSpec = WireSpec::instance().get(); wireSpec->isInternalClient) { WireSpec::appendInternalClientWireVersion(wireSpec->outgoing, &bob); } @@ -589,7 +589,8 @@ bool DBClientBase::isPrimary(bool& isPrimary, BSONObj* info) { if (info == nullptr) info = &o; bool ok = runCommand("admin", bob.obj(), *info); - isPrimary = info->getField("ismaster").trueValue(); + isPrimary = + info->getField(_apiParameters.getVersion() ? "isWritablePrimary" : "ismaster").trueValue(); return ok; } diff --git a/src/mongo/client/dbclient_connection.cpp b/src/mongo/client/dbclient_connection.cpp index a42865be5be..f40b32e76a6 100644 --- a/src/mongo/client/dbclient_connection.cpp +++ b/src/mongo/client/dbclient_connection.cpp @@ -186,7 +186,7 @@ executor::RemoteCommandResponse initWireVersion( ScopedForceOpQuery forceOpQuery{conn}; BSONObjBuilder bob; - bob.append("isMaster", 1); + bob.append(conn->getApiParameters().getVersion() ? "hello" : "isMaster", 1); if (uri.isHelloOk()) { // Attach "helloOk: true" to the initial handshake to indicate that the client supports the diff --git a/src/mongo/client/scanning_replica_set_monitor.cpp b/src/mongo/client/scanning_replica_set_monitor.cpp index daef814d55c..afe643a8d14 100644 --- a/src/mongo/client/scanning_replica_set_monitor.cpp +++ b/src/mongo/client/scanning_replica_set_monitor.cpp @@ -988,7 +988,7 @@ void IsMasterReply::parse(const BSONObj& obj) { maxWireVersion = raw["maxWireVersion"].numberInt(); // hidden nodes can't be master, even if they claim to be. - isMaster = !hidden && raw["ismaster"].trueValue(); + isMaster = !hidden && (raw["isWritablePrimary"].trueValue() || raw["ismaster"].trueValue()); if (isMaster && raw.hasField("electionId")) { electionId = raw["electionId"].OID(); |