summaryrefslogtreecommitdiff
path: root/src/mongo/db/repl/replication_coordinator_impl.cpp
diff options
context:
space:
mode:
authorGregory Wlodarek <gregory.wlodarek@mongodb.com>2020-05-14 22:58:51 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-05-15 17:43:43 +0000
commite4e8a7338834ef224b4d681e7d216a49fb322bfa (patch)
treeb61796867d7dda6c05af8209d72a307c665f073a /src/mongo/db/repl/replication_coordinator_impl.cpp
parent065d4ab364de1fc6b54a500848c5b8c33035ad22 (diff)
downloadmongo-e4e8a7338834ef224b4d681e7d216a49fb322bfa.tar.gz
SERVER-48235 The primary node should use the AsyncDBClient to vote for committing the index build to allow the request to be interrupted by the IndexBuildsCoordinator
Diffstat (limited to 'src/mongo/db/repl/replication_coordinator_impl.cpp')
-rw-r--r--src/mongo/db/repl/replication_coordinator_impl.cpp41
1 files changed, 3 insertions, 38 deletions
diff --git a/src/mongo/db/repl/replication_coordinator_impl.cpp b/src/mongo/db/repl/replication_coordinator_impl.cpp
index 61249d566c9..4c52652bfcc 100644
--- a/src/mongo/db/repl/replication_coordinator_impl.cpp
+++ b/src/mongo/db/repl/replication_coordinator_impl.cpp
@@ -2355,28 +2355,6 @@ void ReplicationCoordinatorImpl::cancelCbkHandle(CallbackHandle activeHandle) {
_replExecutor->cancel(activeHandle);
}
-BSONObj ReplicationCoordinatorImpl::_runCmdOnSelfOnAlternativeClient(OperationContext* opCtx,
- const std::string& dbName,
- const BSONObj& cmdObj) {
-
- auto client = opCtx->getServiceContext()->makeClient("DBDirectClientCmd");
- // We want the command's opCtx that gets executed via DBDirectClient to be interruptible
- // so that we don't block state transitions. Callers of this function might run opCtx
- // in an uninterruptible mode. To be on safer side, run the command in AlternativeClientRegion,
- // to make sure that the command's opCtx is interruptible.
- AlternativeClientRegion acr(client);
- auto uniqueNewOpCtx = cc().makeOperationContext();
- {
- stdx::lock_guard<Client> lk(cc());
- cc().setSystemOperationKillable(lk);
- }
-
- DBDirectClient dbClient(uniqueNewOpCtx.get());
- const auto commandResponse = dbClient.runCommand(OpMsgRequest::fromDBAndBody(dbName, cmdObj));
-
- return commandResponse->getCommandReply();
-}
-
BSONObj ReplicationCoordinatorImpl::runCmdOnPrimaryAndAwaitResponse(
OperationContext* opCtx,
const std::string& dbName,
@@ -2386,27 +2364,14 @@ BSONObj ReplicationCoordinatorImpl::runCmdOnPrimaryAndAwaitResponse(
// About to make network and DBDirectClient (recursive) calls, so we should not hold any locks.
invariant(!opCtx->lockState()->isLocked());
- const auto myHostAndPort = getMyHostAndPort();
const auto primaryHostAndPort = getCurrentPrimaryHostAndPort();
-
- if (myHostAndPort.empty()) {
- // Possibly because either rsconfig is uninitialized or the node got removed from config.
- uassertStatusOK(Status{ErrorCodes::NodeNotFound, "Address unknown."});
- }
-
if (primaryHostAndPort.empty()) {
uassertStatusOK(Status{ErrorCodes::NoConfigMaster, "Primary is unknown/down."});
}
- auto iAmPrimary = (myHostAndPort == primaryHostAndPort) ? true : false;
-
- if (iAmPrimary) {
- // Run command using DBDirectClient to avoid tcp connection.
- return _runCmdOnSelfOnAlternativeClient(opCtx, dbName, cmdObj);
- }
-
- // Node is not primary, so we will run the remote command via AsyncDBClient. To use
- // AsyncDBClient, we will be using repl task executor.
+ // Run the command via AsyncDBClient which performs a network call. This is also the desired
+ // behaviour when running this command locally as to avoid using the DBDirectClient which would
+ // provide additional management when trying to cancel the request with differing clients.
executor::RemoteCommandRequest request(primaryHostAndPort, dbName, cmdObj, nullptr);
executor::RemoteCommandResponse cbkResponse(
Status{ErrorCodes::InternalError, "Uninitialized value"});