summaryrefslogtreecommitdiff
path: root/src/mongo/s/query/cluster_find.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/s/query/cluster_find.cpp')
-rw-r--r--src/mongo/s/query/cluster_find.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/mongo/s/query/cluster_find.cpp b/src/mongo/s/query/cluster_find.cpp
index 27afa51d5a5..57050b408b6 100644
--- a/src/mongo/s/query/cluster_find.cpp
+++ b/src/mongo/s/query/cluster_find.cpp
@@ -444,8 +444,12 @@ StatusWith<CursorResponse> ClusterFind::runGetMore(OperationContext* opCtx,
}
if (next.getValue().isEOF()) {
- // We reached end-of-stream.
- if (!pinnedCursor.getValue().isTailable()) {
+ // We reached end-of-stream. If the cursor is not tailable, then we mark it as
+ // exhausted. If it is tailable, usually we keep it open (i.e. "NotExhausted") even when
+ // we reach end-of-stream. However, if all the remote cursors are exhausted, there is no
+ // hope of returning data and thus we need to close the mongos cursor as well.
+ if (!pinnedCursor.getValue().isTailable() ||
+ pinnedCursor.getValue().remotesExhausted()) {
cursorState = ClusterCursorManager::CursorState::Exhausted;
}
break;