diff options
author | Gregory Wlodarek <gregory.wlodarek@mongodb.com> | 2022-04-05 20:21:29 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-04-07 15:37:23 +0000 |
commit | 55ded8c1cefa67b3d7c1ceeb1e28a8f0bfa45e25 (patch) | |
tree | 45001293a9db22b0901a6d1a5785a4ecd044ca8e /src/mongo/db/query | |
parent | 156a1456c05956125658a90382271d596a10368d (diff) | |
download | mongo-55ded8c1cefa67b3d7c1ceeb1e28a8f0bfa45e25.tar.gz |
SERVER-65261 User deletes on capped collections do not return CappedPositionLost
Diffstat (limited to 'src/mongo/db/query')
-rw-r--r-- | src/mongo/db/query/get_executor.cpp | 4 | ||||
-rw-r--r-- | src/mongo/db/query/internal_plans.cpp | 13 | ||||
-rw-r--r-- | src/mongo/db/query/internal_plans.h | 6 |
3 files changed, 13 insertions, 10 deletions
diff --git a/src/mongo/db/query/get_executor.cpp b/src/mongo/db/query/get_executor.cpp index fbdcfcd4875..b952ca69ea9 100644 --- a/src/mongo/db/query/get_executor.cpp +++ b/src/mongo/db/query/get_executor.cpp @@ -1526,6 +1526,10 @@ StatusWith<std::unique_ptr<PlanExecutor, PlanExecutor::Deleter>> getExecutorDele } } + if (collection && collection->isCapped()) { + expCtx->setIsCappedDelete(); + } + if (collection && collection->isCapped() && opCtx->inMultiDocumentTransaction()) { // This check is duplicated from CollectionImpl::deleteDocument() for two reasons: // - Performing a remove on an empty capped collection would not call diff --git a/src/mongo/db/query/internal_plans.cpp b/src/mongo/db/query/internal_plans.cpp index c6128069392..2e220fcacaa 100644 --- a/src/mongo/db/query/internal_plans.cpp +++ b/src/mongo/db/query/internal_plans.cpp @@ -216,11 +216,14 @@ std::unique_ptr<PlanExecutor, PlanExecutor::Deleter> InternalPlanner::deleteWith auto expCtx = make_intrusive<ExpressionContext>( opCtx, std::unique_ptr<CollatorInterface>(nullptr), collection->ns()); + if (collection->isCapped()) { + expCtx->setIsCappedDelete(); + } + auto collScanParams = createCollectionScanParams( expCtx, ws.get(), coll, direction, boost::none /* resumeAfterId */, minRecord, maxRecord); - auto root = _collectionScan( - expCtx, ws.get(), &collection, collScanParams, true /* relaxCappedConstraints */); + auto root = _collectionScan(expCtx, ws.get(), &collection, collScanParams); if (batchParams) { root = std::make_unique<BatchedDeleteStage>(expCtx.get(), @@ -435,14 +438,12 @@ std::unique_ptr<PlanStage> InternalPlanner::_collectionScan( const boost::intrusive_ptr<ExpressionContext>& expCtx, WorkingSet* ws, const CollectionPtr* coll, - const CollectionScanParams& params, - bool relaxCappedConstraints) { + const CollectionScanParams& params) { const auto& collection = *coll; invariant(collection); - return std::make_unique<CollectionScan>( - expCtx.get(), collection, params, ws, nullptr, relaxCappedConstraints); + return std::make_unique<CollectionScan>(expCtx.get(), collection, params, ws, nullptr); } std::unique_ptr<PlanStage> InternalPlanner::_indexScan( diff --git a/src/mongo/db/query/internal_plans.h b/src/mongo/db/query/internal_plans.h index 79614b09233..190237537b3 100644 --- a/src/mongo/db/query/internal_plans.h +++ b/src/mongo/db/query/internal_plans.h @@ -187,15 +187,13 @@ private: Direction direction, boost::optional<RecordId> resumeAfterRecordId = boost::none, boost::optional<RecordId> minRecord = boost::none, - boost::optional<RecordId> maxRecord = boost::none, - bool relaxCappedConstraints = false); + boost::optional<RecordId> maxRecord = boost::none); static std::unique_ptr<PlanStage> _collectionScan( const boost::intrusive_ptr<ExpressionContext>& expCtx, WorkingSet* ws, const CollectionPtr* collection, - const CollectionScanParams& params, - bool relaxCappedConstraints = false); + const CollectionScanParams& params); /** * Returns a plan stage that is either an index scan or an index scan with a fetch stage. |