summaryrefslogtreecommitdiff
path: root/src/mongo/db/query/sbe_stage_builder_coll_scan.cpp
diff options
context:
space:
mode:
authorHenrik Edin <henrik.edin@mongodb.com>2020-09-17 17:09:19 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-09-26 02:12:49 +0000
commit2b82ab88982566114d1bb7667477b71c883b0799 (patch)
treec152b35ff047fdc42f69aa6cd6b04fee1d811fe4 /src/mongo/db/query/sbe_stage_builder_coll_scan.cpp
parent08e92a678a1ed288f6a95e7950597e082556ae59 (diff)
downloadmongo-2b82ab88982566114d1bb7667477b71c883b0799.tar.gz
SERVER-50984 Add CollectionPtr to replace usage of const Collection*
It implements a yieldable interface that is used to re-load the Collection pointer from the catalog after a yield that released locks. With lock-free reads and copy-on-write on Collection instances releasing locks without notifying an AutoGetCollection at a higher level may cause its pointers to dangle if a MODE_X writer installs a new Collection instance in the catalog. CollectionPtr should be passed by const reference so a yield can notify all the way up.
Diffstat (limited to 'src/mongo/db/query/sbe_stage_builder_coll_scan.cpp')
-rw-r--r--src/mongo/db/query/sbe_stage_builder_coll_scan.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/mongo/db/query/sbe_stage_builder_coll_scan.cpp b/src/mongo/db/query/sbe_stage_builder_coll_scan.cpp
index 8b44fb09c89..bf099dee54d 100644
--- a/src/mongo/db/query/sbe_stage_builder_coll_scan.cpp
+++ b/src/mongo/db/query/sbe_stage_builder_coll_scan.cpp
@@ -54,13 +54,13 @@ namespace {
* Checks whether a callback function should be created for a ScanStage and returns it, if so. The
* logic in the provided callback will be executed when the ScanStage is opened or reopened.
*/
-sbe::ScanOpenCallback makeOpenCallbackIfNeeded(const Collection* collection,
+sbe::ScanOpenCallback makeOpenCallbackIfNeeded(const CollectionPtr& collection,
const CollectionScanNode* csn) {
if (csn->direction == CollectionScanParams::FORWARD && csn->shouldWaitForOplogVisibility) {
invariant(!csn->tailable);
invariant(collection->ns().isOplog());
- return [](OperationContext* opCtx, const Collection* collection, bool reOpen) {
+ return [](OperationContext* opCtx, const CollectionPtr& collection, bool reOpen) {
if (!reOpen) {
// Forward, non-tailable scans from the oplog need to wait until all oplog entries
// before the read begins to be visible. This isn't needed for reverse scans because
@@ -87,7 +87,7 @@ sbe::ScanOpenCallback makeOpenCallbackIfNeeded(const Collection* collection,
* of the same SlotId (the latter is returned purely for convenience purposes).
*/
std::tuple<std::vector<std::string>, sbe::value::SlotVector, boost::optional<sbe::value::SlotId>>
-makeOplogTimestampSlotsIfNeeded(const Collection* collection,
+makeOplogTimestampSlotsIfNeeded(const CollectionPtr& collection,
sbe::value::SlotIdGenerator* slotIdGenerator,
bool shouldTrackLatestOplogTimestamp) {
if (shouldTrackLatestOplogTimestamp) {
@@ -118,7 +118,7 @@ std::tuple<sbe::value::SlotId,
boost::optional<sbe::value::SlotId>,
std::unique_ptr<sbe::PlanStage>>
generateOptimizedOplogScan(OperationContext* opCtx,
- const Collection* collection,
+ const CollectionPtr& collection,
const CollectionScanNode* csn,
sbe::value::SlotIdGenerator* slotIdGenerator,
sbe::value::FrameIdGenerator* frameIdGenerator,
@@ -300,7 +300,7 @@ std::tuple<sbe::value::SlotId,
boost::optional<sbe::value::SlotId>,
std::unique_ptr<sbe::PlanStage>>
generateGenericCollScan(OperationContext* opCtx,
- const Collection* collection,
+ const CollectionPtr& collection,
const CollectionScanNode* csn,
sbe::value::SlotIdGenerator* slotIdGenerator,
sbe::value::FrameIdGenerator* frameIdGenerator,
@@ -447,7 +447,7 @@ std::tuple<sbe::value::SlotId,
boost::optional<sbe::value::SlotId>,
std::unique_ptr<sbe::PlanStage>>
generateCollScan(OperationContext* opCtx,
- const Collection* collection,
+ const CollectionPtr& collection,
const CollectionScanNode* csn,
sbe::value::SlotIdGenerator* slotIdGenerator,
sbe::value::FrameIdGenerator* frameIdGenerator,