diff options
author | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2019-03-21 13:14:40 -0400 |
---|---|---|
committer | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2019-03-21 21:36:47 -0400 |
commit | be36aeb7166b2e06dd47dd0769ea28cbb7250041 (patch) | |
tree | d95db70de0f2ac6cf1d6bc62ef85c657c6cff2f5 /src/mongo/s/client | |
parent | 78eaa3cf538764d5aa5a09c5997532a4c3b2bca8 (diff) | |
download | mongo-be36aeb7166b2e06dd47dd0769ea28cbb7250041.tar.gz |
SERVER-40223 Use the AsyncWorkScheduler to run local command when recovering a coordinator decision
Diffstat (limited to 'src/mongo/s/client')
-rw-r--r-- | src/mongo/s/client/rs_local_client.cpp | 2 | ||||
-rw-r--r-- | src/mongo/s/client/rs_local_client.h | 2 | ||||
-rw-r--r-- | src/mongo/s/client/shard.cpp | 8 | ||||
-rw-r--r-- | src/mongo/s/client/shard.h | 4 | ||||
-rw-r--r-- | src/mongo/s/client/shard_local.cpp | 4 | ||||
-rw-r--r-- | src/mongo/s/client/shard_local.h | 4 | ||||
-rw-r--r-- | src/mongo/s/client/shard_remote.cpp | 15 | ||||
-rw-r--r-- | src/mongo/s/client/shard_remote.h | 6 |
8 files changed, 20 insertions, 25 deletions
diff --git a/src/mongo/s/client/rs_local_client.cpp b/src/mongo/s/client/rs_local_client.cpp index 16bd240b5fa..fdb386a3bcf 100644 --- a/src/mongo/s/client/rs_local_client.cpp +++ b/src/mongo/s/client/rs_local_client.cpp @@ -71,7 +71,7 @@ repl::OpTime RSLocalClient::_getLastOpTime() { } StatusWith<Shard::CommandResponse> RSLocalClient::runCommandOnce(OperationContext* opCtx, - const std::string& dbName, + StringData dbName, const BSONObj& cmdObj) { const auto currentOpTimeFromClient = repl::ReplClientInfo::forClient(opCtx->getClient()).getLastOp(); diff --git a/src/mongo/s/client/rs_local_client.h b/src/mongo/s/client/rs_local_client.h index b31121cd5b7..d12b443b868 100644 --- a/src/mongo/s/client/rs_local_client.h +++ b/src/mongo/s/client/rs_local_client.h @@ -53,7 +53,7 @@ public: * response and write concern error (if present). */ StatusWith<Shard::CommandResponse> runCommandOnce(OperationContext* opCtx, - const std::string& dbName, + StringData dbName, const BSONObj& cmdObj); /** diff --git a/src/mongo/s/client/shard.cpp b/src/mongo/s/client/shard.cpp index 7f6ea898854..e2c751529e2 100644 --- a/src/mongo/s/client/shard.cpp +++ b/src/mongo/s/client/shard.cpp @@ -41,9 +41,6 @@ #include "mongo/util/log.h" namespace mongo { - -using std::string; - namespace { const int kOnErrorNumRetries = 3; @@ -76,7 +73,7 @@ Status Shard::CommandResponse::processBatchWriteResponse( StatusWith<Shard::CommandResponse> swResponse, BatchedCommandResponse* batchResponse) { auto status = getEffectiveStatus(swResponse); if (status.isOK()) { - string errmsg; + std::string errmsg; if (!batchResponse->parseBSON(swResponse.getValue().response, &errmsg)) { status = Status(ErrorCodes::FailedToParse, str::stream() << "Failed to parse write response: " << errmsg); @@ -202,8 +199,7 @@ BatchedCommandResponse Shard::runBatchWriteCommand(OperationContext* opCtx, const Milliseconds maxTimeMS, const BatchedCommandRequest& batchRequest, RetryPolicy retryPolicy) { - const std::string dbname = batchRequest.getNS().db().toString(); - + const StringData dbname = batchRequest.getNS().db(); const BSONObj cmdObj = batchRequest.toBSON(); for (int retry = 1; retry <= kOnErrorNumRetries; ++retry) { diff --git a/src/mongo/s/client/shard.h b/src/mongo/s/client/shard.h index f0d25f99755..69db3fdbc87 100644 --- a/src/mongo/s/client/shard.h +++ b/src/mongo/s/client/shard.h @@ -294,14 +294,14 @@ private: */ virtual StatusWith<CommandResponse> _runCommand(OperationContext* opCtx, const ReadPreferenceSetting& readPref, - const std::string& dbname, + StringData dbname, Milliseconds maxTimeMSOverride, const BSONObj& cmdObj) = 0; virtual StatusWith<QueryResponse> _runExhaustiveCursorCommand( OperationContext* opCtx, const ReadPreferenceSetting& readPref, - const std::string& dbName, + StringData dbName, Milliseconds maxTimeMSOverride, const BSONObj& cmdObj) = 0; diff --git a/src/mongo/s/client/shard_local.cpp b/src/mongo/s/client/shard_local.cpp index 76b849d6fa5..e27dc21f47c 100644 --- a/src/mongo/s/client/shard_local.cpp +++ b/src/mongo/s/client/shard_local.cpp @@ -105,7 +105,7 @@ bool ShardLocal::isRetriableError(ErrorCodes::Error code, RetryPolicy options) { StatusWith<Shard::CommandResponse> ShardLocal::_runCommand(OperationContext* opCtx, const ReadPreferenceSetting& unused, - const std::string& dbName, + StringData dbName, Milliseconds maxTimeMSOverrideUnused, const BSONObj& cmdObj) { return _rsLocalClient.runCommandOnce(opCtx, dbName, cmdObj); @@ -114,7 +114,7 @@ StatusWith<Shard::CommandResponse> ShardLocal::_runCommand(OperationContext* opC StatusWith<Shard::QueryResponse> ShardLocal::_runExhaustiveCursorCommand( OperationContext* opCtx, const ReadPreferenceSetting& readPref, - const std::string& dbName, + StringData dbName, Milliseconds maxTimeMSOverride, const BSONObj& cmdObj) { MONGO_UNREACHABLE; diff --git a/src/mongo/s/client/shard_local.h b/src/mongo/s/client/shard_local.h index fec3bd26abc..17b67378658 100644 --- a/src/mongo/s/client/shard_local.h +++ b/src/mongo/s/client/shard_local.h @@ -74,14 +74,14 @@ public: private: StatusWith<Shard::CommandResponse> _runCommand(OperationContext* opCtx, const ReadPreferenceSetting& unused, - const std::string& dbName, + StringData dbName, Milliseconds maxTimeMSOverrideUnused, const BSONObj& cmdObj) final; StatusWith<Shard::QueryResponse> _runExhaustiveCursorCommand( OperationContext* opCtx, const ReadPreferenceSetting& readPref, - const std::string& dbName, + StringData dbName, Milliseconds maxTimeMSOverride, const BSONObj& cmdObj) final; diff --git a/src/mongo/s/client/shard_remote.cpp b/src/mongo/s/client/shard_remote.cpp index 3a16f44752f..26d9b88daa1 100644 --- a/src/mongo/s/client/shard_remote.cpp +++ b/src/mongo/s/client/shard_remote.cpp @@ -32,7 +32,6 @@ #include "mongo/platform/basic.h" #include "mongo/s/client/shard_remote.h" -#include "mongo/s/client/shard_remote_gen.h" #include <algorithm> #include <string> @@ -51,6 +50,7 @@ #include "mongo/rpc/get_status_from_command_result.h" #include "mongo/rpc/metadata/repl_set_metadata.h" #include "mongo/rpc/metadata/tracking_metadata.h" +#include "mongo/s/client/shard_remote_gen.h" #include "mongo/s/grid.h" #include "mongo/util/log.h" #include "mongo/util/mongoutils/str.h" @@ -58,8 +58,6 @@ namespace mongo { -using std::string; - using executor::RemoteCommandRequest; using executor::RemoteCommandResponse; using executor::TaskExecutor; @@ -67,6 +65,7 @@ using rpc::TrackingMetadata; using RemoteCommandCallbackArgs = TaskExecutor::RemoteCommandCallbackArgs; namespace { + // Include kReplSetMetadataFieldName in a request to get the shard's ReplSetMetadata in the // response. const BSONObj kReplMetadata(BSON(rpc::kReplSetMetadataFieldName << 1)); @@ -183,7 +182,7 @@ BSONObj ShardRemote::_appendMetadataForCommand(OperationContext* opCtx, StatusWith<Shard::CommandResponse> ShardRemote::_runCommand(OperationContext* opCtx, const ReadPreferenceSetting& readPref, - const string& dbName, + StringData dbName, Milliseconds maxTimeMSOverride, const BSONObj& cmdObj) { RemoteCommandResponse response = @@ -245,7 +244,7 @@ StatusWith<Shard::CommandResponse> ShardRemote::_runCommand(OperationContext* op StatusWith<Shard::QueryResponse> ShardRemote::_runExhaustiveCursorCommand( OperationContext* opCtx, const ReadPreferenceSetting& readPref, - const string& dbName, + StringData dbName, Milliseconds maxTimeMSOverride, const BSONObj& cmdObj) { const auto host = _targeter->findHost(opCtx, readPref); @@ -303,7 +302,7 @@ StatusWith<Shard::QueryResponse> ShardRemote::_runExhaustiveCursorCommand( Fetcher fetcher(Grid::get(opCtx)->getExecutorPool()->getFixedExecutor(), host.getValue(), - dbName, + dbName.toString(), cmdObj, fetcherCallback, _appendMetadataForCommand(opCtx, readPref), @@ -401,7 +400,7 @@ void ShardRemote::runFireAndForgetCommand(OperationContext* opCtx, StatusWith<ShardRemote::AsyncCmdHandle> ShardRemote::_scheduleCommand( OperationContext* opCtx, const ReadPreferenceSetting& readPref, - const std::string& dbName, + StringData dbName, Milliseconds maxTimeMSOverride, const BSONObj& cmdObj, const TaskExecutor::RemoteCommandCallbackFn& cb) { @@ -424,7 +423,7 @@ StatusWith<ShardRemote::AsyncCmdHandle> ShardRemote::_scheduleCommand( const RemoteCommandRequest request( asyncHandle.hostTargetted, - dbName, + dbName.toString(), appendMaxTimeToCmdObj(requestTimeout, cmdObj), _appendMetadataForCommand(opCtx, readPrefWithMinOpTime), opCtx, diff --git a/src/mongo/s/client/shard_remote.h b/src/mongo/s/client/shard_remote.h index 8831f08cd54..b5d9b4a7c2e 100644 --- a/src/mongo/s/client/shard_remote.h +++ b/src/mongo/s/client/shard_remote.h @@ -102,14 +102,14 @@ private: StatusWith<Shard::CommandResponse> _runCommand(OperationContext* opCtx, const ReadPreferenceSetting& readPref, - const std::string& dbname, + StringData dbName, Milliseconds maxTimeMSOverride, const BSONObj& cmdObj) final; StatusWith<Shard::QueryResponse> _runExhaustiveCursorCommand( OperationContext* opCtx, const ReadPreferenceSetting& readPref, - const std::string& dbName, + StringData dbName, Milliseconds maxTimeMSOverride, const BSONObj& cmdObj) final; @@ -125,7 +125,7 @@ private: StatusWith<AsyncCmdHandle> _scheduleCommand( OperationContext* opCtx, const ReadPreferenceSetting& readPref, - const std::string& dbName, + StringData dbName, Milliseconds maxTimeMSOverride, const BSONObj& cmdObj, const executor::TaskExecutor::RemoteCommandCallbackFn& cb); |