diff options
Diffstat (limited to 'src/mongo/s/query/async_results_merger.cpp')
-rw-r--r-- | src/mongo/s/query/async_results_merger.cpp | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/src/mongo/s/query/async_results_merger.cpp b/src/mongo/s/query/async_results_merger.cpp index 8b23528a04a..c82de6a3bbe 100644 --- a/src/mongo/s/query/async_results_merger.cpp +++ b/src/mongo/s/query/async_results_merger.cpp @@ -51,15 +51,6 @@ namespace { // Maximum number of retries for network and replication notMaster errors (per host). const int kMaxNumFailedHostRetryAttempts = 3; -/** - * Returns whether a particular error code returned from the initial cursor establishment should - * be retried. - */ -bool isPerShardRetriableError(ErrorCodes::Error err) { - return (ShardRegistry::kAllRetriableErrors.count(err) || - err == ErrorCodes::NotMasterOrSecondary); -} - } // namespace AsyncResultsMerger::AsyncResultsMerger(executor::TaskExecutor* executor, @@ -438,8 +429,7 @@ void AsyncResultsMerger::handleBatchResponse( if (!cursorResponseStatus.isOK()) { // Notify the shard registry of the failure. if (remote.shardId) { - // TODO: Pass down an OperationContext* to use here. - auto shard = grid.shardRegistry()->getShard(nullptr, *remote.shardId); + auto shard = grid.shardRegistry()->getShardNoReload(*remote.shardId); if (!shard) { remote.status = Status(cursorResponseStatus.getStatus().code(), str::stream() << "Could not find shard " << *remote.shardId @@ -453,7 +443,10 @@ void AsyncResultsMerger::handleBatchResponse( // If the error is retriable, schedule another request. if (!remote.cursorId && remote.retryCount < kMaxNumFailedHostRetryAttempts && - isPerShardRetriableError(cursorResponseStatus.getStatus().code())) { + ShardRegistry::kAllRetriableErrors.count(cursorResponseStatus.getStatus().code())) { + LOG(1) << "Initial cursor establishment failed with retriable error and will be retried" + << causedBy(cursorResponseStatus.getStatus()); + ++remote.retryCount; // Since we potentially updated the targeter that the last host it chose might be @@ -641,13 +634,13 @@ Status AsyncResultsMerger::RemoteCursorData::resolveShardIdToHostAndPort( invariant(shardId); invariant(!cursorId); - // TODO: Pass down an OperationContext* to use here. - const auto shard = grid.shardRegistry()->getShard(nullptr, *shardId); + const auto shard = grid.shardRegistry()->getShardNoReload(*shardId); if (!shard) { return Status(ErrorCodes::ShardNotFound, str::stream() << "Could not find shard " << *shardId); } + // TODO: Pass down an OperationContext* to use here. auto findHostStatus = shard->getTargeter()->findHost( readPref, RemoteCommandTargeter::selectFindHostMaxWaitTime(nullptr)); if (!findHostStatus.isOK()) { |