summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPavi Vetriselvan <pavithra.vetriselvan@mongodb.com>2020-07-30 12:39:35 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-08-05 20:32:26 +0000
commit9a4be902441496be7ef40e5404a91ac30dc81f77 (patch)
treea80cbd4b37c00c347a8ac40cc111031532034400
parent52f4d4d869dca67d7ed22e8956d9fb56a8a79944 (diff)
downloadmongo-9a4be902441496be7ef40e5404a91ac30dc81f77.tar.gz
SERVER-49986 Convert isMaster command to hello and keep isMaster, ismaster aliases
-rw-r--r--jstests/core/ismaster.js97
-rw-r--r--jstests/core/list_commands.js14
-rw-r--r--jstests/core/views/views_all_commands.js3
-rw-r--r--jstests/replsets/db_reads_while_recovering_all_commands.js2
-rw-r--r--jstests/replsets/writes_during_tenant_migration.js2
-rw-r--r--jstests/sharding/database_versioning_all_commands.js3
-rw-r--r--jstests/sharding/ismaster.js95
-rw-r--r--jstests/sharding/read_write_concern_defaults_application.js3
-rw-r--r--jstests/sharding/safe_secondary_reads_drop_recreate.js3
-rw-r--r--jstests/sharding/safe_secondary_reads_single_migration_suspend_range_deletion.js3
-rw-r--r--jstests/sharding/safe_secondary_reads_single_migration_waitForDelete.js3
-rw-r--r--src/mongo/db/repl/replication_info.cpp15
-rw-r--r--src/mongo/db/service_entry_point_common.cpp5
-rw-r--r--src/mongo/s/commands/cluster_is_master_cmd.cpp15
-rw-r--r--src/mongo/s/commands/strategy.cpp2
15 files changed, 163 insertions, 102 deletions
diff --git a/jstests/core/ismaster.js b/jstests/core/ismaster.js
index a29be88331c..3a0d55324c0 100644
--- a/jstests/core/ismaster.js
+++ b/jstests/core/ismaster.js
@@ -1,45 +1,62 @@
+/**
+ * This test ensures that the hello command and its aliases, ismaster and isMaster, are all
+ * accepted.
+ * @tags: [requires_fcv_47]
+ */
"use strict";
-var res = db.isMaster();
-// check that the fields that should be there are there and have proper values
-assert(res.maxBsonObjectSize && isNumber(res.maxBsonObjectSize) && res.maxBsonObjectSize > 0,
- "maxBsonObjectSize possibly missing:" + tojson(res));
-assert(res.maxMessageSizeBytes && isNumber(res.maxMessageSizeBytes) && res.maxBsonObjectSize > 0,
- "maxMessageSizeBytes possibly missing:" + tojson(res));
-assert(res.maxWriteBatchSize && isNumber(res.maxWriteBatchSize) && res.maxWriteBatchSize > 0,
- "maxWriteBatchSize possibly missing:" + tojson(res));
-assert.eq("boolean", typeof res.ismaster, "ismaster field is not a boolean" + tojson(res));
-assert(res.ismaster === true, "ismaster field is false" + tojson(res));
-assert(res.localTime, "localTime possibly missing:" + tojson(res));
-assert(res.connectionId, "connectionId missing or false" + tojson(res));
-if (!testingReplication) {
- var badFields = [];
- var unwantedReplSetFields = [
- "setName",
- "setVersion",
- "secondary",
- "hosts",
- "passives",
- "arbiters",
- "primary",
- "aribterOnly",
- "passive",
- "slaveDelay",
- "hidden",
- "tags",
- "buildIndexes",
- "me"
- ];
- var field;
- // check that the fields that shouldn't be there are not there
- for (field in res) {
- if (!res.hasOwnProperty(field)) {
- continue;
- }
- if (Array.contains(unwantedReplSetFields, field)) {
- badFields.push(field);
+function checkResponseFields(commandString) {
+ var res = db.runCommand(commandString);
+ // check that the fields that should be there are there and have proper values
+ assert(res.maxBsonObjectSize && isNumber(res.maxBsonObjectSize) && res.maxBsonObjectSize > 0,
+ "maxBsonObjectSize possibly missing:" + tojson(res));
+ assert(
+ res.maxMessageSizeBytes && isNumber(res.maxMessageSizeBytes) && res.maxBsonObjectSize > 0,
+ "maxMessageSizeBytes possibly missing:" + tojson(res));
+ assert(res.maxWriteBatchSize && isNumber(res.maxWriteBatchSize) && res.maxWriteBatchSize > 0,
+ "maxWriteBatchSize possibly missing:" + tojson(res));
+ assert.eq("boolean", typeof res.ismaster, "ismaster field is not a boolean" + tojson(res));
+
+ // TODO SERVER-49988: Check for res.isWritablePrimary instead of res.ismaster if a hello command
+ // was executed.
+ assert(res.ismaster === true, "ismaster field is false" + tojson(res));
+ assert(res.localTime, "localTime possibly missing:" + tojson(res));
+ assert(res.connectionId, "connectionId missing or false" + tojson(res));
+
+ if (!testingReplication) {
+ var badFields = [];
+ var unwantedReplSetFields = [
+ "setName",
+ "setVersion",
+ "secondary",
+ "hosts",
+ "passives",
+ "arbiters",
+ "primary",
+ "aribterOnly",
+ "passive",
+ "slaveDelay",
+ "hidden",
+ "tags",
+ "buildIndexes",
+ "me"
+ ];
+ var field;
+ // check that the fields that shouldn't be there are not there
+ for (field in res) {
+ if (!res.hasOwnProperty(field)) {
+ continue;
+ }
+ if (Array.contains(unwantedReplSetFields, field)) {
+ badFields.push(field);
+ }
}
+ assert(
+ badFields.length === 0,
+ "\nthe result:\n" + tojson(res) + "\ncontained fields it shouldn't have: " + badFields);
}
- assert(badFields.length === 0,
- "\nthe result:\n" + tojson(res) + "\ncontained fields it shouldn't have: " + badFields);
}
+
+checkResponseFields("hello");
+checkResponseFields("ismaster");
+checkResponseFields("isMaster");
diff --git a/jstests/core/list_commands.js b/jstests/core/list_commands.js
index 6e63c179dfb..05c83db2b1f 100644
--- a/jstests/core/list_commands.js
+++ b/jstests/core/list_commands.js
@@ -22,19 +22,19 @@ assert(isSorted(commands));
// Test that result contains basic commands.
assert(commands.hasOwnProperty("commands"));
-assert(commands["commands"].hasOwnProperty("isMaster"));
+assert(commands["commands"].hasOwnProperty("hello"));
assert(commands["commands"].hasOwnProperty("insert"));
assert(commands["commands"].hasOwnProperty("ping"));
// Test that commands listed have required properties
-const isMaster = commands["commands"]["isMaster"];
-assert(isMaster.hasOwnProperty("help"));
-assert(isMaster.hasOwnProperty("slaveOk"));
-assert(isMaster.hasOwnProperty("adminOnly"));
-assert(isMaster.hasOwnProperty("requiresAuth"));
+const hello = commands["commands"]["hello"];
+assert(hello.hasOwnProperty("help"));
+assert(hello.hasOwnProperty("slaveOk"));
+assert(hello.hasOwnProperty("adminOnly"));
+assert(hello.hasOwnProperty("requiresAuth"));
// Test that requiresAuth outputs correct value
const insert = commands["commands"]["insert"];
-assert(isMaster["requiresAuth"] === false);
+assert(hello["requiresAuth"] === false);
assert(insert["requiresAuth"] === true);
})();
diff --git a/jstests/core/views/views_all_commands.js b/jstests/core/views/views_all_commands.js
index 57344485f8c..6623b5b8c0d 100644
--- a/jstests/core/views/views_all_commands.js
+++ b/jstests/core/views/views_all_commands.js
@@ -7,6 +7,7 @@
// requires_non_retryable_commands,
// requires_non_retryable_writes,
// uses_map_reduce_with_temp_collections,
+// requires_fcv_47,
// ]
/*
@@ -333,13 +334,13 @@ let viewsCommandTests = {
grantRolesToRole: {skip: isUnrelated},
grantRolesToUser: {skip: isUnrelated},
handshake: {skip: isUnrelated},
+ hello: {skip: isUnrelated},
hostInfo: {skip: isUnrelated},
httpClientRequest: {skip: isAnInternalCommand},
insert: {command: {insert: "view", documents: [{x: 1}]}, expectFailure: true},
internalRenameIfOptionsAndIndexesMatch: {skip: isAnInternalCommand},
invalidateUserCache: {skip: isUnrelated},
isdbgrid: {skip: isUnrelated},
- isMaster: {skip: isUnrelated},
killCursors: {
setup: function(conn) {
assert.commandWorked(conn.collection.remove({}));
diff --git a/jstests/replsets/db_reads_while_recovering_all_commands.js b/jstests/replsets/db_reads_while_recovering_all_commands.js
index 6670bc1458c..3199178f16b 100644
--- a/jstests/replsets/db_reads_while_recovering_all_commands.js
+++ b/jstests/replsets/db_reads_while_recovering_all_commands.js
@@ -188,12 +188,12 @@ const allCommands = {
grantPrivilegesToRole: {skip: isPrimaryOnly},
grantRolesToRole: {skip: isPrimaryOnly},
grantRolesToUser: {skip: isPrimaryOnly},
+ hello: {skip: isNotAUserDataRead},
hostInfo: {skip: isNotAUserDataRead},
httpClientRequest: {skip: isNotAUserDataRead},
insert: {skip: isPrimaryOnly},
internalRenameIfOptionsAndIndexesMatch: {skip: isAnInternalCommand},
invalidateUserCache: {skip: isNotAUserDataRead},
- isMaster: {skip: isNotAUserDataRead},
killAllSessions: {skip: isNotAUserDataRead},
killAllSessionsByPattern: {skip: isNotAUserDataRead},
killCursors: {skip: isNotAUserDataRead},
diff --git a/jstests/replsets/writes_during_tenant_migration.js b/jstests/replsets/writes_during_tenant_migration.js
index b9a48af39ba..f6dfe5a686c 100644
--- a/jstests/replsets/writes_during_tenant_migration.js
+++ b/jstests/replsets/writes_during_tenant_migration.js
@@ -663,6 +663,7 @@ const testCases = {
grantPrivilegesToRole: {skip: isAuthCommand},
grantRolesToRole: {skip: isAuthCommand},
grantRolesToUser: {skip: isAuthCommand},
+ hello: {skip: isNotRunOnUserDatabase},
hostInfo: {skip: isNotRunOnUserDatabase},
httpClientRequest: {skip: isNotRunOnUserDatabase},
insert: {
@@ -681,7 +682,6 @@ const testCases = {
},
internalRenameIfOptionsAndIndexesMatch: {skip: isNotRunOnUserDatabase},
invalidateUserCache: {skip: isNotRunOnUserDatabase},
- isMaster: {skip: isNotRunOnUserDatabase},
killAllSessions: {skip: isNotRunOnUserDatabase},
killAllSessionsByPattern: {skip: isNotRunOnUserDatabase},
killCursors: {skip: isNotWriteCommand},
diff --git a/jstests/sharding/database_versioning_all_commands.js b/jstests/sharding/database_versioning_all_commands.js
index bf7fba3a2ca..804da523ba1 100644
--- a/jstests/sharding/database_versioning_all_commands.js
+++ b/jstests/sharding/database_versioning_all_commands.js
@@ -1,6 +1,7 @@
/**
* Specifies for each command whether it is expected to send a databaseVersion, and verifies that
* the commands match the specification.
+ * @tags: [requires_fcv_47]
*/
(function() {
'use strict';
@@ -451,6 +452,7 @@ let testCases = {
grantPrivilegesToRole: {skip: "always targets the config server"},
grantRolesToRole: {skip: "always targets the config server"},
grantRolesToUser: {skip: "always targets the config server"},
+ hello: {skip: "executes locally on mongos (not sent to any remote node)"},
hostInfo: {skip: "executes locally on mongos (not sent to any remote node)"},
insert: {
run: {
@@ -462,7 +464,6 @@ let testCases = {
},
invalidateUserCache: {skip: "executes locally on mongos (not sent to any remote node)"},
isdbgrid: {skip: "executes locally on mongos (not sent to any remote node)"},
- isMaster: {skip: "executes locally on mongos (not sent to any remote node)"},
killCursors: {skip: "requires a previously established cursor"},
killAllSessions: {skip: "always broadcast to all hosts in the cluster"},
killAllSessionsByPattern: {skip: "always broadcast to all hosts in the cluster"},
diff --git a/jstests/sharding/ismaster.js b/jstests/sharding/ismaster.js
index 2d5cea7b586..d1ce254d711 100644
--- a/jstests/sharding/ismaster.js
+++ b/jstests/sharding/ismaster.js
@@ -1,42 +1,63 @@
+/**
+ * This test ensures that the hello command and its aliases, ismaster and isMaster, are all
+ * accepted by mongos.
+ * @tags: [requires_fcv_47]
+ */
"use strict";
var st = new ShardingTest({shards: 1, mongos: 1});
-var res = st.s0.getDB("admin").runCommand("ismaster");
-// check that the fields that should be there are there and have proper values
-assert(res.maxBsonObjectSize && isNumber(res.maxBsonObjectSize) && res.maxBsonObjectSize > 0,
- "maxBsonObjectSize possibly missing:" + tojson(res));
-assert(res.maxMessageSizeBytes && isNumber(res.maxMessageSizeBytes) && res.maxBsonObjectSize > 0,
- "maxMessageSizeBytes possibly missing:" + tojson(res));
-assert.eq("boolean", typeof res.ismaster, "ismaster field is not a boolean" + tojson(res));
-assert(res.ismaster === true, "ismaster field is false" + tojson(res));
-assert(res.localTime, "localTime possibly missing:" + tojson(res));
-assert(res.msg && res.msg == "isdbgrid", "msg possibly missing or wrong:" + tojson(res));
-var unwantedFields = [
- "setName",
- "setVersion",
- "secondary",
- "hosts",
- "passives",
- "arbiters",
- "primary",
- "aribterOnly",
- "passive",
- "slaveDelay",
- "hidden",
- "tags",
- "buildIndexes",
- "me"
-];
-// check that the fields that shouldn't be there are not there
-var badFields = [];
-var field;
-for (field in res) {
- if (!res.hasOwnProperty(field)) {
- continue;
- }
- if (Array.contains(unwantedFields, field)) {
- badFields.push(field);
+
+function checkResponseFields(commandString) {
+ jsTestLog("Running the " + commandString + " command");
+ var res = st.s0.getDB("admin").runCommand(commandString);
+
+ // check that the fields that should be there are there and have proper values
+ assert(res.maxBsonObjectSize && isNumber(res.maxBsonObjectSize) && res.maxBsonObjectSize > 0,
+ "maxBsonObjectSize possibly missing:" + tojson(res));
+ assert(
+ res.maxMessageSizeBytes && isNumber(res.maxMessageSizeBytes) && res.maxBsonObjectSize > 0,
+ "maxMessageSizeBytes possibly missing:" + tojson(res));
+
+ // TODO SERVER-49988: Check for res.isWritablePrimary instead of res.ismaster if a hello command
+ // was executed.
+ assert.eq("boolean", typeof res.ismaster, "ismaster field is not a boolean" + tojson(res));
+ assert(res.ismaster === true, "ismaster field is false" + tojson(res));
+
+ assert(res.localTime, "localTime possibly missing:" + tojson(res));
+ assert(res.msg && res.msg == "isdbgrid", "msg possibly missing or wrong:" + tojson(res));
+
+ var unwantedFields = [
+ "setName",
+ "setVersion",
+ "secondary",
+ "hosts",
+ "passives",
+ "arbiters",
+ "primary",
+ "aribterOnly",
+ "passive",
+ "slaveDelay",
+ "hidden",
+ "tags",
+ "buildIndexes",
+ "me"
+ ];
+ // check that the fields that shouldn't be there are not there
+ var badFields = [];
+ var field;
+ for (field in res) {
+ if (!res.hasOwnProperty(field)) {
+ continue;
+ }
+ if (Array.contains(unwantedFields, field)) {
+ badFields.push(field);
+ }
}
+ assert(badFields.length === 0,
+ "\nthe result:\n" + tojson(res) + "\ncontained fields it shouldn't have: " + badFields);
}
-assert(badFields.length === 0,
- "\nthe result:\n" + tojson(res) + "\ncontained fields it shouldn't have: " + badFields);
+
+checkResponseFields("hello");
+checkResponseFields("ismaster");
+checkResponseFields("isMaster");
+
st.stop();
diff --git a/jstests/sharding/read_write_concern_defaults_application.js b/jstests/sharding/read_write_concern_defaults_application.js
index c45fbc86f43..3f3332ac209 100644
--- a/jstests/sharding/read_write_concern_defaults_application.js
+++ b/jstests/sharding/read_write_concern_defaults_application.js
@@ -26,6 +26,7 @@
* requires_majority_read_concern,
* requires_profiling,
* uses_transactions,
+ * requires_fcv_47
* ]
*/
(function() {
@@ -455,6 +456,7 @@ let testCases = {
useLogs: true,
},
handshake: {skip: "does not accept read or write concern"},
+ hello: {skip: "does not accept read or write concern"},
hostInfo: {skip: "does not accept read or write concern"},
httpClientRequest: {skip: "does not accept read or write concern"},
insert: {
@@ -467,7 +469,6 @@ let testCases = {
},
internalRenameIfOptionsAndIndexesMatch: {skip: "internal command"},
invalidateUserCache: {skip: "does not accept read or write concern"},
- isMaster: {skip: "does not accept read or write concern"},
isdbgrid: {skip: "does not accept read or write concern"},
killAllSessions: {skip: "does not accept read or write concern"},
killAllSessionsByPattern: {skip: "does not accept read or write concern"},
diff --git a/jstests/sharding/safe_secondary_reads_drop_recreate.js b/jstests/sharding/safe_secondary_reads_drop_recreate.js
index 6a03af25df7..489cdf720e9 100644
--- a/jstests/sharding/safe_secondary_reads_drop_recreate.js
+++ b/jstests/sharding/safe_secondary_reads_drop_recreate.js
@@ -15,6 +15,7 @@
* *when the the collection has been dropped and recreated as empty.*
* - behavior: Must be "unshardedOnly", or "versioned". Determines what system profiler checks are
* performed.
+ * @tags: [requires_fcv_47]
*/
(function() {
"use strict";
@@ -190,11 +191,11 @@ let testCases = {
grantRolesToRole: {skip: "primary only"},
grantRolesToUser: {skip: "primary only"},
handshake: {skip: "does not return user data"},
+ hello: {skip: "does not return user data"},
hostInfo: {skip: "does not return user data"},
insert: {skip: "primary only"},
invalidateUserCache: {skip: "does not return user data"},
isdbgrid: {skip: "does not return user data"},
- isMaster: {skip: "does not return user data"},
killAllSessions: {skip: "does not return user data"},
killAllSessionsByPattern: {skip: "does not return user data"},
killCursors: {skip: "does not return user data"},
diff --git a/jstests/sharding/safe_secondary_reads_single_migration_suspend_range_deletion.js b/jstests/sharding/safe_secondary_reads_single_migration_suspend_range_deletion.js
index 260de634468..1c1797b78dd 100644
--- a/jstests/sharding/safe_secondary_reads_single_migration_suspend_range_deletion.js
+++ b/jstests/sharding/safe_secondary_reads_single_migration_suspend_range_deletion.js
@@ -22,6 +22,7 @@
* results for the command run with read concern 'available'.
* - behavior: Must be one of "unshardedOnly", "targetsPrimaryUsesConnectionVersioning" or
* "versioned". Determines what system profiler checks are performed.
+ * @tags: [requires_fcv_47]
*/
(function() {
"use strict";
@@ -224,11 +225,11 @@ let testCases = {
grantRolesToRole: {skip: "primary only"},
grantRolesToUser: {skip: "primary only"},
handshake: {skip: "does not return user data"},
+ hello: {skip: "does not return user data"},
hostInfo: {skip: "does not return user data"},
insert: {skip: "primary only"},
invalidateUserCache: {skip: "does not return user data"},
isdbgrid: {skip: "does not return user data"},
- isMaster: {skip: "does not return user data"},
killCursors: {skip: "does not return user data"},
killAllSessions: {skip: "does not return user data"},
killAllSessionsByPattern: {skip: "does not return user data"},
diff --git a/jstests/sharding/safe_secondary_reads_single_migration_waitForDelete.js b/jstests/sharding/safe_secondary_reads_single_migration_waitForDelete.js
index c502137fc03..490b0d0c60a 100644
--- a/jstests/sharding/safe_secondary_reads_single_migration_waitForDelete.js
+++ b/jstests/sharding/safe_secondary_reads_single_migration_waitForDelete.js
@@ -15,6 +15,7 @@
* *when the range has been deleted on the donor.*
* - behavior: Must be one of "unshardedOnly", "targetsPrimaryUsesConnectionVersioning" or
* "versioned". Determines what system profiler checks are performed.
+ * @tags: [requires_fcv_47]
*/
(function() {
"use strict";
@@ -195,11 +196,11 @@ let testCases = {
grantRolesToRole: {skip: "primary only"},
grantRolesToUser: {skip: "primary only"},
handshake: {skip: "does not return user data"},
+ hello: {skip: "does not return user data"},
hostInfo: {skip: "does not return user data"},
insert: {skip: "primary only"},
invalidateUserCache: {skip: "does not return user data"},
isdbgrid: {skip: "does not return user data"},
- isMaster: {skip: "does not return user data"},
killAllSessions: {skip: "does not return user data"},
killAllSessionsByPattern: {skip: "does not return user data"},
killCursors: {skip: "does not return user data"},
diff --git a/src/mongo/db/repl/replication_info.cpp b/src/mongo/db/repl/replication_info.cpp
index a76cefbcce7..5fb4459aea0 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/base/string_data.h"
#include "mongo/bson/util/bson_extract.h"
#include "mongo/client/connpool.h"
#include "mongo/client/dbclient_connection.h"
@@ -79,6 +80,12 @@ using std::unique_ptr;
namespace repl {
namespace {
+
+constexpr auto kHelloString = "hello"_sd;
+// Aliases for the hello command in order to provide backwards compatibility.
+constexpr auto kCamelCaseIsMasterString = "isMaster"_sd;
+constexpr auto kLowerCaseIsMasterString = "ismaster"_sd;
+
/**
* Appends replication-related fields to the isMaster response. Returns the topology version that
* was included in the response.
@@ -221,9 +228,11 @@ public:
}
} oplogInfoServerStatus;
-class CmdIsMaster final : public BasicCommandWithReplyBuilderInterface {
+class CmdHello final : public BasicCommandWithReplyBuilderInterface {
public:
- CmdIsMaster() : BasicCommandWithReplyBuilderInterface("isMaster", "ismaster") {}
+ CmdHello()
+ : BasicCommandWithReplyBuilderInterface(
+ kHelloString, {kCamelCaseIsMasterString, kLowerCaseIsMasterString}) {}
const std::set<std::string>& apiVersions() const {
return kApiVersions1;
@@ -480,7 +489,7 @@ public:
return true;
}
-} cmdismaster;
+} cmdhello;
OpCounterServerStatusSection replOpCounterServerStatusSection("opcountersRepl", &replOpCounters);
diff --git a/src/mongo/db/service_entry_point_common.cpp b/src/mongo/db/service_entry_point_common.cpp
index 6717fc5589d..5b4c5856ee2 100644
--- a/src/mongo/db/service_entry_point_common.cpp
+++ b/src/mongo/db/service_entry_point_common.cpp
@@ -1362,7 +1362,7 @@ DbResponse receivedCommands(OperationContext* opCtx,
const auto session = opCtx->getClient()->session();
if (session) {
- if (!opCtx->isExhaust() || c->getName() != "isMaster"_sd) {
+ if (!opCtx->isExhaust() || c->getName() != "hello"_sd) {
InExhaustIsMaster::get(session.get())->setInExhaustIsMaster(false);
}
}
@@ -1703,8 +1703,7 @@ Future<DbResponse> ServiceEntryPointCommon::handleRequest(OperationContext* opCt
if (op == dbMsg || (op == dbQuery && isCommand)) {
dbresponse = receivedCommands(opCtx, m, behaviors);
// IsMaster should take kMaxAwaitTimeMs at most, log if it takes twice that.
- if (auto command = currentOp.getCommand();
- command && (command->getName() == "ismaster" || command->getName() == "isMaster")) {
+ if (auto command = currentOp.getCommand(); command && (command->getName() == "hello")) {
slowMsOverride =
2 * durationCount<Milliseconds>(SingleServerIsMasterMonitor::kMaxAwaitTime);
}
diff --git a/src/mongo/s/commands/cluster_is_master_cmd.cpp b/src/mongo/s/commands/cluster_is_master_cmd.cpp
index 5c9a0fdb698..5e864ec3532 100644
--- a/src/mongo/s/commands/cluster_is_master_cmd.cpp
+++ b/src/mongo/s/commands/cluster_is_master_cmd.cpp
@@ -30,6 +30,7 @@
#include "mongo/platform/basic.h"
+#include "mongo/base/string_data.h"
#include "mongo/bson/util/bson_extract.h"
#include "mongo/db/auth/sasl_mechanism_registry.h"
#include "mongo/db/client.h"
@@ -55,9 +56,17 @@ MONGO_FAIL_POINT_DEFINE(waitInIsMaster);
namespace {
-class CmdIsMaster : public BasicCommandWithReplyBuilderInterface {
+constexpr auto kHelloString = "hello"_sd;
+// Aliases for the hello command in order to provide backwards compatibility.
+constexpr auto kCamelCaseIsMasterString = "isMaster"_sd;
+constexpr auto kLowerCaseIsMasterString = "ismaster"_sd;
+
+
+class CmdHello : public BasicCommandWithReplyBuilderInterface {
public:
- CmdIsMaster() : BasicCommandWithReplyBuilderInterface("isMaster", "ismaster") {}
+ CmdHello()
+ : BasicCommandWithReplyBuilderInterface(
+ kHelloString, {kCamelCaseIsMasterString, kLowerCaseIsMasterString}) {}
const std::set<std::string>& apiVersions() const {
return kApiVersions1;
@@ -228,7 +237,7 @@ public:
return true;
}
-} isMaster;
+} hello;
} // namespace
} // namespace mongo
diff --git a/src/mongo/s/commands/strategy.cpp b/src/mongo/s/commands/strategy.cpp
index f90d6d1beb6..744fd0008e5 100644
--- a/src/mongo/s/commands/strategy.cpp
+++ b/src/mongo/s/commands/strategy.cpp
@@ -315,7 +315,7 @@ void runCommand(OperationContext* opCtx,
opCtx->setExhaust(OpMsg::isFlagSet(m, OpMsg::kExhaustSupported));
const auto session = opCtx->getClient()->session();
if (session) {
- if (!opCtx->isExhaust() || command->getName() != "isMaster"_sd) {
+ if (!opCtx->isExhaust() || command->getName() != "hello"_sd) {
InExhaustIsMaster::get(session.get())->setInExhaustIsMaster(false);
}
}