summaryrefslogtreecommitdiff
path: root/src/mongo
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo')
-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.cpp23
4 files changed, 20 insertions, 38 deletions
diff --git a/src/mongo/db/repl/replication_info.cpp b/src/mongo/db/repl/replication_info.cpp
index 8685a30ecb8..617ac34bfc2 100644
--- a/src/mongo/db/repl/replication_info.cpp
+++ b/src/mongo/db/repl/replication_info.cpp
@@ -33,7 +33,6 @@
#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"
@@ -82,12 +81,6 @@ 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.
@@ -299,11 +292,9 @@ public:
}
} oplogInfoServerStatus;
-class CmdHello final : public BasicCommandWithReplyBuilderInterface {
+class CmdIsMaster final : public BasicCommandWithReplyBuilderInterface {
public:
- CmdHello()
- : BasicCommandWithReplyBuilderInterface(
- kHelloString, {kCamelCaseIsMasterString, kLowerCaseIsMasterString}) {}
+ CmdIsMaster() : BasicCommandWithReplyBuilderInterface("isMaster", "ismaster") {}
bool requiresAuth() const final {
return false;
@@ -561,7 +552,7 @@ public:
return true;
}
-} cmdhello;
+} cmdismaster;
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 b14d1c88f38..1a4c7fdf239 100644
--- a/src/mongo/db/service_entry_point_common.cpp
+++ b/src/mongo/db/service_entry_point_common.cpp
@@ -1379,7 +1379,7 @@ DbResponse receivedCommands(OperationContext* opCtx,
const auto session = opCtx->getClient()->session();
if (session) {
- if (!opCtx->isExhaust() || c->getName() != "hello"_sd) {
+ if (!opCtx->isExhaust() || c->getName() != "isMaster"_sd) {
InExhaustIsMaster::get(session.get())->setInExhaustIsMaster(false);
}
}
@@ -1716,7 +1716,8 @@ DbResponse ServiceEntryPointCommon::handleRequest(OperationContext* opCtx,
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() == "hello")) {
+ if (auto command = currentOp.getCommand();
+ command && (command->getName() == "ismaster" || command->getName() == "isMaster")) {
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 bb0fb7fec3b..a71c0c28ef2 100644
--- a/src/mongo/s/commands/cluster_is_master_cmd.cpp
+++ b/src/mongo/s/commands/cluster_is_master_cmd.cpp
@@ -30,7 +30,6 @@
#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"
@@ -67,17 +66,9 @@ MONGO_INITIALIZER(GenerateMongosTopologyVersion)(InitializerContext*) {
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;
-
-
-class CmdHello : public BasicCommandWithReplyBuilderInterface {
+class CmdIsMaster : public BasicCommandWithReplyBuilderInterface {
public:
- CmdHello()
- : BasicCommandWithReplyBuilderInterface(
- kHelloString, {kCamelCaseIsMasterString, kLowerCaseIsMasterString}) {}
+ CmdIsMaster() : BasicCommandWithReplyBuilderInterface("isMaster", "ismaster") {}
bool supportsWriteConcern(const BSONObj& cmd) const override {
return false;
@@ -254,7 +245,7 @@ public:
return true;
}
-} hello;
+} isMaster;
} // namespace
} // namespace mongo
diff --git a/src/mongo/s/commands/strategy.cpp b/src/mongo/s/commands/strategy.cpp
index b08550220d6..7d4e5912fa3 100644
--- a/src/mongo/s/commands/strategy.cpp
+++ b/src/mongo/s/commands/strategy.cpp
@@ -354,10 +354,9 @@ MONGO_FAIL_POINT_DEFINE(doNotRefreshShardsOnRetargettingError);
*/
void runCommand(OperationContext* opCtx,
const OpMsgRequest& request,
- const Message& m,
+ const NetworkOp opType,
rpc::ReplyBuilderInterface* replyBuilder,
BSONObjBuilder* errorBuilder) {
- auto const opType = m.operation();
auto const commandName = request.getCommandName();
auto const command = CommandHelpers::findCommand(commandName);
if (!command) {
@@ -370,14 +369,6 @@ void runCommand(OperationContext* opCtx,
return;
}
- opCtx->setExhaust(OpMsg::isFlagSet(m, OpMsg::kExhaustSupported));
- const auto session = opCtx->getClient()->session();
- if (session) {
- if (!opCtx->isExhaust() || command->getName() != "hello"_sd) {
- InExhaustIsMaster::get(session.get())->setInExhaustIsMaster(false);
- }
- }
-
CommandHelpers::uassertShouldAttemptParse(opCtx, command, request);
// Parse the 'maxTimeMS' command option, and use it to set a deadline for the operation on
@@ -1047,6 +1038,14 @@ DbResponse Strategy::clientCommand(OperationContext* opCtx, const Message& m) {
}
}();
+ opCtx->setExhaust(OpMsg::isFlagSet(m, OpMsg::kExhaustSupported));
+ const auto session = opCtx->getClient()->session();
+ if (session) {
+ if (!opCtx->isExhaust() || request.getCommandName() != "isMaster"_sd) {
+ InExhaustIsMaster::get(session.get())->setInExhaustIsMaster(false);
+ }
+ }
+
// Execute.
std::string db = request.getDatabase().toString();
try {
@@ -1056,7 +1055,7 @@ DbResponse Strategy::clientCommand(OperationContext* opCtx, const Message& m) {
"Command begin",
"db"_attr = db,
"headerId"_attr = m.header().getId());
- runCommand(opCtx, request, m, reply.get(), &errorBuilder);
+ runCommand(opCtx, request, m.operation(), reply.get(), &errorBuilder);
LOGV2_DEBUG(22771,
3,
"Command end db: {db} msg id: {headerId}",
@@ -1274,7 +1273,7 @@ void Strategy::writeOp(OperationContext* opCtx, DbMessage* dbm) {
MONGO_UNREACHABLE;
}
}(),
- msg,
+ msg.operation(),
&reply,
&errorBuilder); // built objects are ignored
}