diff options
author | Henrik Edin <henrik.edin@mongodb.com> | 2020-09-17 17:09:19 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-09-26 02:12:49 +0000 |
commit | 2b82ab88982566114d1bb7667477b71c883b0799 (patch) | |
tree | c152b35ff047fdc42f69aa6cd6b04fee1d811fe4 /src/mongo/db/exec/geo_near.cpp | |
parent | 08e92a678a1ed288f6a95e7950597e082556ae59 (diff) | |
download | mongo-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/exec/geo_near.cpp')
-rw-r--r-- | src/mongo/db/exec/geo_near.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/mongo/db/exec/geo_near.cpp b/src/mongo/db/exec/geo_near.cpp index e55f085a85f..8f97ab6107a 100644 --- a/src/mongo/db/exec/geo_near.cpp +++ b/src/mongo/db/exec/geo_near.cpp @@ -266,7 +266,7 @@ static R2Annulus twoDDistanceBounds(const GeoNearParams& nearParams, return fullBounds; } -GeoNear2DStage::DensityEstimator::DensityEstimator(const Collection* collection, +GeoNear2DStage::DensityEstimator::DensityEstimator(const CollectionPtr& collection, PlanStage::Children* children, BSONObj infoObj, const GeoNearParams* nearParams, @@ -454,7 +454,7 @@ static const string kTwoDIndexNearStage("GEO_NEAR_2D"); GeoNear2DStage::GeoNear2DStage(const GeoNearParams& nearParams, ExpressionContext* expCtx, WorkingSet* workingSet, - const Collection* collection, + const CollectionPtr& collection, const IndexDescriptor* twoDIndex) : NearStage(expCtx, kTwoDIndexNearStage.c_str(), @@ -480,7 +480,7 @@ public: WorkingSet* ws, std::unique_ptr<PlanStage> child, MatchExpression* filter, - const Collection* collection) + const CollectionPtr& collection) : FetchStage(expCtx, ws, std::move(child), filter, collection), _matcher(filter) {} private: @@ -520,7 +520,7 @@ static R2Annulus projectBoundsToTwoDDegrees(R2Annulus sphereBounds) { } std::unique_ptr<NearStage::CoveredInterval> GeoNear2DStage::nextInterval( - OperationContext* opCtx, WorkingSet* workingSet, const Collection* collection) { + OperationContext* opCtx, WorkingSet* workingSet, const CollectionPtr& collection) { // The search is finished if we searched at least once and all the way to the edge if (_currBounds.getInner() >= 0 && _currBounds.getOuter() == _fullBounds.getOuter()) { return nullptr; @@ -697,7 +697,7 @@ static const string kS2IndexNearStage("GEO_NEAR_2DSPHERE"); GeoNear2DSphereStage::GeoNear2DSphereStage(const GeoNearParams& nearParams, ExpressionContext* expCtx, WorkingSet* workingSet, - const Collection* collection, + const CollectionPtr& collection, const IndexDescriptor* s2Index) : NearStage(expCtx, kS2IndexNearStage.c_str(), @@ -762,7 +762,7 @@ S2Region* buildS2Region(const R2Annulus& sphereBounds) { } } // namespace -GeoNear2DSphereStage::DensityEstimator::DensityEstimator(const Collection* collection, +GeoNear2DSphereStage::DensityEstimator::DensityEstimator(const CollectionPtr& collection, PlanStage::Children* children, const GeoNearParams* nearParams, const S2IndexingParams& indexParams, @@ -919,7 +919,7 @@ PlanStage::StageState GeoNear2DSphereStage::initialize(OperationContext* opCtx, } std::unique_ptr<NearStage::CoveredInterval> GeoNear2DSphereStage::nextInterval( - OperationContext* opCtx, WorkingSet* workingSet, const Collection* collection) { + OperationContext* opCtx, WorkingSet* workingSet, const CollectionPtr& collection) { // The search is finished if we searched at least once and all the way to the edge if (_currBounds.getInner() >= 0 && _currBounds.getOuter() == _fullBounds.getOuter()) { return nullptr; |