diff options
Diffstat (limited to 'src/mongo')
-rw-r--r-- | src/mongo/s/commands/cluster_is_master_cmd.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/mongo/s/commands/cluster_is_master_cmd.cpp b/src/mongo/s/commands/cluster_is_master_cmd.cpp index ed3f8181d4c..490605fbefe 100644 --- a/src/mongo/s/commands/cluster_is_master_cmd.cpp +++ b/src/mongo/s/commands/cluster_is_master_cmd.cpp @@ -83,6 +83,12 @@ public: const BSONObj& cmdObj, BSONObjBuilder& result) override { CommandHelpers::handleMarkKillOnClientDisconnect(opCtx); + + // Parse the command name, which should be one of the following: hello, isMaster, or + // ismaster. If the command is "hello", we must attach an "isWritablePrimary" response field + // instead of "ismaster". + bool useLegacyResponseFields = (cmdObj.firstElementFieldNameStringData() != kHelloString); + auto& clientMetadataIsMasterState = ClientMetadataIsMasterState::get(opCtx->getClient()); bool seenIsMaster = clientMetadataIsMasterState.hasSeenIsMaster(); if (!seenIsMaster) { @@ -112,7 +118,11 @@ public: opCtx->getClient(), std::move(swParseClientMetadata.getValue())); } - result.appendBool("ismaster", true); + if (useLegacyResponseFields) { + result.appendBool("ismaster", true); + } else { + result.appendBool("isWritablePrimary", true); + } result.append("msg", "isdbgrid"); result.appendNumber("maxBsonObjectSize", BSONObjMaxUserSize); result.appendNumber("maxMessageSizeBytes", MaxMessageSizeBytes); |