summaryrefslogtreecommitdiff
path: root/src/mongo/dbtests/query_stage_subplan.cpp
diff options
context:
space:
mode:
authorHenrik Edin <henrik.edin@mongodb.com>2020-09-30 11:19:31 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-10-13 00:32:43 +0000
commitbcab0c7e1c1b2e1516d06d23233fea9a425b99f7 (patch)
tree8d805048d69ece52bb64e740532f5968b671865c /src/mongo/dbtests/query_stage_subplan.cpp
parent0dadef8dd93175bf3a75412d8a32b377d9eba42c (diff)
downloadmongo-bcab0c7e1c1b2e1516d06d23233fea9a425b99f7.tar.gz
SERVER-51200 CollectionPtr in RequiresCollectionStage point to instance owned by AutoGetCollection
RequiresCollectionStage now holds a pointer to CollectionPtr owned by an AutoGetCollection. When we save and restore the executor a new CollectionPtr pointer needs to be assigned. Plan executors can no longer be created with temporary CollectionPtr instances and their interface have been changed to take pointers to avoid binding to rvalues. RequiresCollectionStage no longer loads collections from the catalog and will be in sync with the owning AutoGetCollection.
Diffstat (limited to 'src/mongo/dbtests/query_stage_subplan.cpp')
-rw-r--r--src/mongo/dbtests/query_stage_subplan.cpp16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/mongo/dbtests/query_stage_subplan.cpp b/src/mongo/dbtests/query_stage_subplan.cpp
index facd2746bbe..8609b3f8af7 100644
--- a/src/mongo/dbtests/query_stage_subplan.cpp
+++ b/src/mongo/dbtests/query_stage_subplan.cpp
@@ -538,8 +538,8 @@ TEST_F(QueryStageSubplanTest, ShouldReportErrorIfExceedsTimeLimitDuringPlanning)
// Create the SubplanStage.
WorkingSet workingSet;
- SubplanStage subplanStage(
- _expCtx.get(), ctx.getCollection(), &workingSet, params, canonicalQuery.get());
+ auto coll = ctx.getCollection();
+ SubplanStage subplanStage(_expCtx.get(), coll, &workingSet, params, canonicalQuery.get());
AlwaysTimeOutYieldPolicy alwaysTimeOutPolicy(serviceContext()->getFastClockSource());
ASSERT_EQ(ErrorCodes::ExceededTimeLimit, subplanStage.pickBestPlan(&alwaysTimeOutPolicy));
@@ -563,8 +563,8 @@ TEST_F(QueryStageSubplanTest, ShouldReportErrorIfKilledDuringPlanning) {
// Create the SubplanStage.
WorkingSet workingSet;
- SubplanStage subplanStage(
- _expCtx.get(), ctx.getCollection(), &workingSet, params, canonicalQuery.get());
+ auto coll = ctx.getCollection();
+ SubplanStage subplanStage(_expCtx.get(), coll, &workingSet, params, canonicalQuery.get());
AlwaysPlanKilledYieldPolicy alwaysPlanKilledYieldPolicy(serviceContext()->getFastClockSource());
ASSERT_EQ(ErrorCodes::QueryPlanKilled, subplanStage.pickBestPlan(&alwaysPlanKilledYieldPolicy));
@@ -611,11 +611,13 @@ TEST_F(QueryStageSubplanTest, ShouldThrowOnRestoreIfIndexDroppedBeforePlanSelect
// Attempt to restore state. This should throw due the index drop. As a future improvement, we
// may wish to make the subplan stage tolerate drops of indices it is not using.
collLock.emplace(opCtx(), nss);
- ASSERT_THROWS_CODE(subplanStage.restoreState(), DBException, ErrorCodes::QueryPlanKilled);
+ ASSERT_THROWS_CODE(subplanStage.restoreState(&collLock->getCollection()),
+ DBException,
+ ErrorCodes::QueryPlanKilled);
}
TEST_F(QueryStageSubplanTest, ShouldNotThrowOnRestoreIfIndexDroppedAfterPlanSelection) {
- CollectionPtr collection = nullptr;
+ CollectionPtr collection;
{
dbtests::WriteContextForTests ctx{opCtx(), nss.ns()};
addIndex(BSON("p1" << 1 << "opt1" << 1));
@@ -658,7 +660,7 @@ TEST_F(QueryStageSubplanTest, ShouldNotThrowOnRestoreIfIndexDroppedAfterPlanSele
// Restoring state should succeed, since the plan selected by pickBestPlan() does not use the
// index {irrelevant: 1}.
collLock.emplace(opCtx(), nss);
- subplanStage.restoreState();
+ subplanStage.restoreState(&collLock->getCollection());
}
} // namespace