summaryrefslogtreecommitdiff
path: root/src/mongo/db/pipeline
diff options
context:
space:
mode:
authorXiangyu Yao <xiangyu.yao@mongodb.com>2018-06-13 15:21:28 -0400
committerXiangyu Yao <xiangyu.yao@mongodb.com>2018-06-19 17:09:50 -0400
commit1871507cdbdd492abee785076203467d20e0e716 (patch)
treecbd4419e90783af801ad3a239bdff4b27211e385 /src/mongo/db/pipeline
parent1026f5e41426b85b49f3987028f2a63e17012aa6 (diff)
downloadmongo-1871507cdbdd492abee785076203467d20e0e716.tar.gz
SERVER-34113 Remove all support for snapshot reads outside multi-document transactions
Diffstat (limited to 'src/mongo/db/pipeline')
-rw-r--r--src/mongo/db/pipeline/expression_context.h2
-rw-r--r--src/mongo/db/pipeline/pipeline.cpp5
-rw-r--r--src/mongo/db/pipeline/pipeline_test.cpp26
3 files changed, 13 insertions, 20 deletions
diff --git a/src/mongo/db/pipeline/expression_context.h b/src/mongo/db/pipeline/expression_context.h
index 27401d9403e..ed5dd84b251 100644
--- a/src/mongo/db/pipeline/expression_context.h
+++ b/src/mongo/db/pipeline/expression_context.h
@@ -197,7 +197,7 @@ public:
bool inMongos = false;
bool allowDiskUse = false;
bool bypassDocumentValidation = false;
- bool inSnapshotReadOrMultiDocumentTransaction = false;
+ bool inMultiDocumentTransaction = false;
NamespaceString ns;
diff --git a/src/mongo/db/pipeline/pipeline.cpp b/src/mongo/db/pipeline/pipeline.cpp
index 6654b836a3e..dcd8359324f 100644
--- a/src/mongo/db/pipeline/pipeline.cpp
+++ b/src/mongo/db/pipeline/pipeline.cpp
@@ -231,10 +231,9 @@ void Pipeline::validateCommon() const {
str::stream() << stage->getSourceName() << " can only be run on mongoS",
!(constraints.hostRequirement == HostTypeRequirement::kMongoS && !pCtx->inMongos));
- if (pCtx->inSnapshotReadOrMultiDocumentTransaction) {
+ if (pCtx->inMultiDocumentTransaction) {
uassert(50742,
- str::stream() << "Stage not supported with readConcern level \"snapshot\" "
- "or inside of a multi-document transaction: "
+ str::stream() << "Stage not supported inside of a multi-document transaction: "
<< stage->getSourceName(),
constraints.isAllowedInTransaction());
}
diff --git a/src/mongo/db/pipeline/pipeline_test.cpp b/src/mongo/db/pipeline/pipeline_test.cpp
index a0573014a1b..537f7a23ab0 100644
--- a/src/mongo/db/pipeline/pipeline_test.cpp
+++ b/src/mongo/db/pipeline/pipeline_test.cpp
@@ -2427,9 +2427,9 @@ TEST_F(PipelineValidateTest, ChangeStreamIsNotValidIfNotFirstStageInFacet) {
ASSERT(std::string::npos != parseStatus.reason().find("$changeStream"));
}
-class DocumentSourceDisallowedWithSnapshotReads : public DocumentSourceMock {
+class DocumentSourceDisallowedInTransactions : public DocumentSourceMock {
public:
- DocumentSourceDisallowedWithSnapshotReads() : DocumentSourceMock({}) {}
+ DocumentSourceDisallowedInTransactions() : DocumentSourceMock({}) {}
StageConstraints constraints(Pipeline::SplitState pipeState) const final {
return StageConstraints{StreamType::kStreaming,
@@ -2440,42 +2440,36 @@ public:
TransactionRequirement::kNotAllowed};
}
- static boost::intrusive_ptr<DocumentSourceDisallowedWithSnapshotReads> create() {
- return new DocumentSourceDisallowedWithSnapshotReads();
+ static boost::intrusive_ptr<DocumentSourceDisallowedInTransactions> create() {
+ return new DocumentSourceDisallowedInTransactions();
}
};
-TEST_F(PipelineValidateTest, TopLevelPipelineValidatedForStagesIllegalWithSnapshotReads) {
+TEST_F(PipelineValidateTest, TopLevelPipelineValidatedForStagesIllegalInTransactions) {
BSONObj readConcernSnapshot = BSON("readConcern" << BSON("level"
<< "snapshot"));
auto ctx = getExpCtx();
- auto&& readConcernArgs = repl::ReadConcernArgs::get(ctx->opCtx);
- ASSERT_OK(readConcernArgs.initialize(readConcernSnapshot["readConcern"]));
- ASSERT(readConcernArgs.getLevel() == repl::ReadConcernLevel::kSnapshotReadConcern);
- ctx->inSnapshotReadOrMultiDocumentTransaction = true;
+ ctx->inMultiDocumentTransaction = true;
// Make a pipeline with a legal $match, and then an illegal mock stage, and verify that pipeline
// creation fails with the expected error code.
auto matchStage = DocumentSourceMatch::create(BSON("_id" << 3), ctx);
- auto illegalStage = DocumentSourceDisallowedWithSnapshotReads::create();
+ auto illegalStage = DocumentSourceDisallowedInTransactions::create();
auto pipeline = Pipeline::create({matchStage, illegalStage}, ctx);
ASSERT_NOT_OK(pipeline.getStatus());
ASSERT_EQ(pipeline.getStatus(), ErrorCodes::duplicateCodeForTest(50742));
}
-TEST_F(PipelineValidateTest, FacetPipelineValidatedForStagesIllegalWithSnapshotReads) {
+TEST_F(PipelineValidateTest, FacetPipelineValidatedForStagesIllegalInTransactions) {
BSONObj readConcernSnapshot = BSON("readConcern" << BSON("level"
<< "snapshot"));
auto ctx = getExpCtx();
- auto&& readConcernArgs = repl::ReadConcernArgs::get(ctx->opCtx);
- ASSERT_OK(readConcernArgs.initialize(readConcernSnapshot["readConcern"]));
- ASSERT(readConcernArgs.getLevel() == repl::ReadConcernLevel::kSnapshotReadConcern);
- ctx->inSnapshotReadOrMultiDocumentTransaction = true;
+ ctx->inMultiDocumentTransaction = true;
// Make a pipeline with a legal $match, and then an illegal mock stage, and verify that pipeline
// creation fails with the expected error code.
auto matchStage = DocumentSourceMatch::create(BSON("_id" << 3), ctx);
- auto illegalStage = DocumentSourceDisallowedWithSnapshotReads::create();
+ auto illegalStage = DocumentSourceDisallowedInTransactions::create();
auto pipeline = Pipeline::createFacetPipeline({matchStage, illegalStage}, ctx);
ASSERT_NOT_OK(pipeline.getStatus());
ASSERT_EQ(pipeline.getStatus(), ErrorCodes::duplicateCodeForTest(50742));