diff options
author | Gregory Wlodarek <gregory.wlodarek@mongodb.com> | 2020-05-14 22:58:51 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-05-15 17:43:43 +0000 |
commit | e4e8a7338834ef224b4d681e7d216a49fb322bfa (patch) | |
tree | b61796867d7dda6c05af8209d72a307c665f073a | |
parent | 065d4ab364de1fc6b54a500848c5b8c33035ad22 (diff) | |
download | mongo-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
-rw-r--r-- | src/mongo/db/repl/replication_coordinator_impl.cpp | 41 | ||||
-rw-r--r-- | src/mongo/db/repl/replication_coordinator_impl.h | 8 |
2 files changed, 3 insertions, 46 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"}); diff --git a/src/mongo/db/repl/replication_coordinator_impl.h b/src/mongo/db/repl/replication_coordinator_impl.h index b3dacb2982b..cf2e1dad7d7 100644 --- a/src/mongo/db/repl/replication_coordinator_impl.h +++ b/src/mongo/db/repl/replication_coordinator_impl.h @@ -1435,14 +1435,6 @@ private: int64_t _nextRandomInt64_inlock(int64_t limit); /** - * Runs the command using DBDirectClient and returns the response received for that command. - * Callers of this function should not hold any locks. - */ - BSONObj _runCmdOnSelfOnAlternativeClient(OperationContext* opCtx, - const std::string& dbName, - const BSONObj& cmdObj); - - /** * This is called by a primary when they become aware that a node has completed initial sync. * That primary initiates a reconfig to remove the 'newlyAdded' for that node, if it was set. */ |