diff options
author | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2016-02-26 15:27:25 -0500 |
---|---|---|
committer | Ramon Fernandez <ramon@mongodb.com> | 2016-02-29 16:10:09 -0500 |
commit | a263d39b03a1cf4f199745e0afe06a0d8c734518 (patch) | |
tree | 336003ab62b506b1000ffc433fa8e84f50dc4753 | |
parent | 5866f2bd0c8a76ea61d343e25a876efa39a21d41 (diff) | |
download | mongo-a263d39b03a1cf4f199745e0afe06a0d8c734518.tar.gz |
SERVER-22849 Always update the visible opTime
This change makes sure that the ShardRegistry does not skip updating the
config server visible opTime, even if the commands come back with
command-specific errors.
(cherry picked from commit 81efb319f05f4ec1b5bd4523b13694241e967fc2)
-rw-r--r-- | src/mongo/s/client/shard_registry.cpp | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/src/mongo/s/client/shard_registry.cpp b/src/mongo/s/client/shard_registry.cpp index aedeed8b1fa..bc7f956da15 100644 --- a/src/mongo/s/client/shard_registry.cpp +++ b/src/mongo/s/client/shard_registry.cpp @@ -530,8 +530,8 @@ StatusWith<ShardRegistry::QueryResponse> ShardRegistry::_exhaustiveFindOnConfig( Status status = Status(ErrorCodes::InternalError, "Internal error running find command"); QueryResponse response; - auto fetcherCallback = [&status, &response](const Fetcher::QueryResponseStatus& dataStatus, - Fetcher::NextAction* nextAction) { + auto fetcherCallback = [this, &status, &response]( + const Fetcher::QueryResponseStatus& dataStatus, Fetcher::NextAction* nextAction) { // Throw out any accumulated results on error if (!dataStatus.isOK()) { @@ -552,6 +552,7 @@ StatusWith<ShardRegistry::QueryResponse> ShardRegistry::_exhaustiveFindOnConfig( } response.opTime = replParseStatus.getValue().getLastOpVisible(); + advanceConfigOpTime(response.opTime); } for (const BSONObj& doc : data.documents) { @@ -613,8 +614,6 @@ StatusWith<ShardRegistry::QueryResponse> ShardRegistry::_exhaustiveFindOnConfig( return status; } - advanceConfigOpTime(response.opTime); - return response; } @@ -716,7 +715,6 @@ StatusWith<BSONObj> ShardRegistry::runCommandOnConfig(OperationContext* txn, return response.getStatus(); } - advanceConfigOpTime(response.getValue().visibleOpTime); return response.getValue().response; } @@ -759,7 +757,6 @@ StatusWith<BSONObj> ShardRegistry::runCommandOnConfigWithRetries( return response.getStatus(); } - advanceConfigOpTime(response.getValue().visibleOpTime); return response.getValue().response; } @@ -838,15 +835,6 @@ StatusWith<ShardRegistry::CommandResponse> ShardRegistry::_runCommandWithMetadat Status commandSpecificStatus = getStatusFromCommandResult(response.data); updateReplSetMonitor(targeter, host.getValue(), commandSpecificStatus); - if (errorsToCheck.count(commandSpecificStatus.code())) { - return commandSpecificStatus; - } - - Status writeConcernStatus = checkForWriteConcernError(response.data); - if (!writeConcernStatus.isOK()) { - return writeConcernStatus; - } - CommandResponse cmdResponse; cmdResponse.response = response.data.getOwned(); cmdResponse.metadata = response.metadata.getOwned(); @@ -860,6 +848,19 @@ StatusWith<ShardRegistry::CommandResponse> ShardRegistry::_runCommandWithMetadat const auto& replMetadata = replParseStatus.getValue(); cmdResponse.visibleOpTime = replMetadata.getLastOpVisible(); + + if (shard->isConfig()) { + advanceConfigOpTime(cmdResponse.visibleOpTime); + } + } + + if (errorsToCheck.count(commandSpecificStatus.code())) { + return commandSpecificStatus; + } + + Status writeConcernStatus = checkForWriteConcernError(response.data); + if (!writeConcernStatus.isOK()) { + return writeConcernStatus; } return StatusWith<CommandResponse>(std::move(cmdResponse)); |