summaryrefslogtreecommitdiff
path: root/src/mongo/s/query/async_results_merger.cpp
diff options
context:
space:
mode:
authorDavid Storch <david.storch@10gen.com>2015-09-22 18:08:36 -0400
committerDavid Storch <david.storch@10gen.com>2015-09-24 20:04:21 -0400
commit549d1080fe68fdef42182d4a4189fdd70f964eaf (patch)
treea72b834ba750998caaf23b54e7aee1f9976cec66 /src/mongo/s/query/async_results_merger.cpp
parentb332a0f555e0d332d3b3d77878187597a23e140b (diff)
downloadmongo-549d1080fe68fdef42182d4a4189fdd70f964eaf.tar.gz
SERVER-19842 support allowPartialResults query option in new mongos read path
Diffstat (limited to 'src/mongo/s/query/async_results_merger.cpp')
-rw-r--r--src/mongo/s/query/async_results_merger.cpp22
1 files changed, 19 insertions, 3 deletions
diff --git a/src/mongo/s/query/async_results_merger.cpp b/src/mongo/s/query/async_results_merger.cpp
index ef039eadb2f..abecbba1a34 100644
--- a/src/mongo/s/query/async_results_merger.cpp
+++ b/src/mongo/s/query/async_results_merger.cpp
@@ -369,9 +369,14 @@ void AsyncResultsMerger::handleBatchResponse(
if (!cbData.response.isOK()) {
remote.status = cbData.response.getStatus();
- // If we failed to retrieve the batch because we couldn't contact the remote, we notify that
- // targeter that the host is unreachable. The caller can then retry on a new host.
- if (remote.status == ErrorCodes::HostUnreachable && remote.shardId) {
+ // Errors other than HostUnreachable have no special handling.
+ if (remote.status != ErrorCodes::HostUnreachable) {
+ return;
+ }
+
+ // Notify that targeter that the host is unreachable. The caller can then retry on a new
+ // host.
+ if (remote.shardId) {
auto shard = _params.shardRegistry->getShard(_params.txn, *remote.shardId);
if (!shard) {
remote.status =
@@ -383,6 +388,17 @@ void AsyncResultsMerger::handleBatchResponse(
}
}
+ // Unreachable host errors are swallowed if the 'allowPartialResults' option is set. We
+ // remove the unreachable host entirely from consideration by marking it as exhausted.
+ if (_params.isAllowPartialResults) {
+ remote.status = Status::OK();
+
+ // Clear the results buffer and cursor id.
+ std::queue<BSONObj> emptyBuffer;
+ std::swap(remote.docBuffer, emptyBuffer);
+ remote.cursorId = 0;
+ }
+
return;
}