summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCharlie Swanson <charlie.swanson@mongodb.com>2018-10-26 13:21:10 -0400
committerCharlie Swanson <charlie.swanson@mongodb.com>2018-11-07 09:50:09 -0500
commit505114314a5f4309f2857573db442604cb0e2b26 (patch)
tree925a6c921b8405d59ae976bad9439887a6e4a8c9 /src
parentf3349bac21f200cf2f9854eb51b359d3cbee3617 (diff)
downloadmongo-505114314a5f4309f2857573db442604cb0e2b26.tar.gz
SERVER-37779 Step up enforcement that $changeStream must be first
Adds an additional check which enforces a $changeStream stage must be the first stage in the pipeline which is robust to the case where a $changeStream is only ever sent to a mongos.
Diffstat (limited to 'src')
-rw-r--r--src/mongo/db/pipeline/document_source_change_stream_transform.cpp5
-rw-r--r--src/mongo/db/pipeline/document_source_check_invalidate.cpp2
2 files changed, 5 insertions, 2 deletions
diff --git a/src/mongo/db/pipeline/document_source_change_stream_transform.cpp b/src/mongo/db/pipeline/document_source_change_stream_transform.cpp
index 150b310b30c..405a3bd303c 100644
--- a/src/mongo/db/pipeline/document_source_change_stream_transform.cpp
+++ b/src/mongo/db/pipeline/document_source_change_stream_transform.cpp
@@ -434,6 +434,11 @@ DocumentSource::GetModPathsReturn DocumentSourceChangeStreamTransform::getModifi
DocumentSource::GetNextResult DocumentSourceChangeStreamTransform::getNext() {
pExpCtx->checkForInterrupt();
+ uassert(50988,
+ "Illegal attempt to execute an internal change stream stage on mongos. A $changeStream "
+ "stage must be the first stage in a pipeline",
+ !pExpCtx->inMongos);
+
// If we're unwinding an 'applyOps' from a transaction, check if there are any documents we have
// stored that can be returned.
if (_txnContext) {
diff --git a/src/mongo/db/pipeline/document_source_check_invalidate.cpp b/src/mongo/db/pipeline/document_source_check_invalidate.cpp
index cedc45598ea..6a86fb8491e 100644
--- a/src/mongo/db/pipeline/document_source_check_invalidate.cpp
+++ b/src/mongo/db/pipeline/document_source_check_invalidate.cpp
@@ -62,8 +62,6 @@ bool isInvalidatingCommand(const boost::intrusive_ptr<ExpressionContext>& pExpCt
DocumentSource::GetNextResult DocumentSourceCheckInvalidate::getNext() {
pExpCtx->checkForInterrupt();
- invariant(!pExpCtx->inMongos);
-
if (_queuedInvalidate) {
const auto res = DocumentSource::GetNextResult(std::move(_queuedInvalidate.get()));
_queuedInvalidate.reset();