summaryrefslogtreecommitdiff
path: root/src/mongo/db/pipeline/document_source_facet.cpp
diff options
context:
space:
mode:
authorEddie Louie <eddie.louie@mongodb.com>2017-08-01 19:47:26 -0400
committerEddie Louie <eddie.louie@mongodb.com>2017-08-01 19:47:26 -0400
commitbabab967892f81f3107903cb41672503de791998 (patch)
tree2b5565bde7d88b251911215be7569766a25d5fdd /src/mongo/db/pipeline/document_source_facet.cpp
parent2a76bd75d75197d3604643ff2b11d0a8f23c14f9 (diff)
downloadmongo-babab967892f81f3107903cb41672503de791998.tar.gz
Revert "SERVER-29506 Require $changeNotification to be the first stage."
This reverts commit 2431e1356823d898ef8af16997d6f63b65b385a5.
Diffstat (limited to 'src/mongo/db/pipeline/document_source_facet.cpp')
-rw-r--r--src/mongo/db/pipeline/document_source_facet.cpp27
1 files changed, 14 insertions, 13 deletions
diff --git a/src/mongo/db/pipeline/document_source_facet.cpp b/src/mongo/db/pipeline/document_source_facet.cpp
index aba1f5f115c..992f3daac11 100644
--- a/src/mongo/db/pipeline/document_source_facet.cpp
+++ b/src/mongo/db/pipeline/document_source_facet.cpp
@@ -99,6 +99,13 @@ vector<pair<string, vector<BSONObj>>> extractRawPipelines(const BSONElement& ele
<< ": "
<< subPipeElem,
subPipeElem.type() == BSONType::Object);
+ auto stageName = subPipeElem.Obj().firstElementFieldName();
+ uassert(
+ 40331,
+ str::stream() << "specified stage is not allowed to be used within a $facet stage: "
+ << subPipeElem,
+ !str::equals(stageName, "$out") && !str::equals(stageName, "$facet"));
+
rawPipeline.push_back(subPipeElem.embeddedObject());
}
@@ -237,22 +244,16 @@ void DocumentSourceFacet::doReattachToOperationContext(OperationContext* opCtx)
}
}
-DocumentSource::StageConstraints DocumentSourceFacet::constraints() const {
- StageConstraints constraints;
- constraints.isAllowedInsideFacetStage = false; // Disallow nested $facets.
-
+bool DocumentSourceFacet::needsPrimaryShard() const {
+ // Currently we don't split $facet to have a merger part and a shards part (see SERVER-24154).
+ // This means that if any stage in any of the $facet pipelines requires the primary shard, then
+ // the entire $facet must happen on the merger, and the merger must be the primary shard.
for (auto&& facet : _facets) {
- for (auto&& nestedStage : facet.pipeline->getSources()) {
- if (nestedStage->constraints().mustRunOnPrimaryShardIfSharded) {
- // Currently we don't split $facet to have a merger part and a shards part (see
- // SERVER-24154). This means that if any stage in any of the $facet pipelines
- // requires the primary shard, then the entire $facet must happen on the merger, and
- // the merger must be the primary shard.
- constraints.mustRunOnPrimaryShardIfSharded = true;
- }
+ if (facet.pipeline->needsPrimaryShardMerger()) {
+ return true;
}
}
- return constraints;
+ return false;
}
DocumentSource::GetDepsReturn DocumentSourceFacet::getDependencies(DepsTracker* deps) const {