diff options
Diffstat (limited to 'src/mongo')
-rw-r--r-- | src/mongo/db/pipeline/document_source_change_stream.cpp | 5 | ||||
-rw-r--r-- | src/mongo/s/query/cluster_find.cpp | 8 |
2 files changed, 10 insertions, 3 deletions
diff --git a/src/mongo/db/pipeline/document_source_change_stream.cpp b/src/mongo/db/pipeline/document_source_change_stream.cpp index cc9d0fed9c9..6b73b4b5084 100644 --- a/src/mongo/db/pipeline/document_source_change_stream.cpp +++ b/src/mongo/db/pipeline/document_source_change_stream.cpp @@ -228,7 +228,10 @@ list<intrusive_ptr<DocumentSource>> DocumentSourceChangeStream::createFromBson( !expCtx->getCollator()); auto replCoord = repl::ReplicationCoordinator::get(expCtx->opCtx); - uassert(40573, "The $changeStream stage is only supported on replica sets", replCoord); + uassert(40573, + "The $changeStream stage is only supported on replica sets", + replCoord && + replCoord->getReplicationMode() == repl::ReplicationCoordinator::Mode::modeReplSet); Timestamp startFrom = replCoord->getMyLastAppliedOpTime().getTimestamp(); intrusive_ptr<DocumentSource> resumeStage = nullptr; 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; |