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.h | |
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.h')
-rw-r--r-- | src/mongo/db/exec/geo_near.h | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/mongo/db/exec/geo_near.h b/src/mongo/db/exec/geo_near.h index 08001ecc77c..d29d7536bea 100644 --- a/src/mongo/db/exec/geo_near.h +++ b/src/mongo/db/exec/geo_near.h @@ -71,13 +71,13 @@ public: GeoNear2DStage(const GeoNearParams& nearParams, ExpressionContext* expCtx, WorkingSet* workingSet, - const Collection* collection, + const CollectionPtr& collection, const IndexDescriptor* twoDIndex); protected: std::unique_ptr<CoveredInterval> nextInterval(OperationContext* opCtx, WorkingSet* workingSet, - const Collection* collection) final; + const CollectionPtr& collection) final; double computeDistance(WorkingSetMember* member) final; @@ -88,7 +88,7 @@ protected: private: class DensityEstimator { public: - DensityEstimator(const Collection* collection, + DensityEstimator(const CollectionPtr& collection, PlanStage::Children* children, BSONObj infoObj, const GeoNearParams* nearParams, @@ -105,7 +105,7 @@ private: WorkingSet* workingSet, const IndexDescriptor* twoDIndex); - const Collection* _collection; + const CollectionPtr& _collection; PlanStage::Children* _children; // Points to PlanStage::_children in the NearStage. const GeoNearParams* _nearParams; // Not owned here. const R2Annulus& _fullBounds; @@ -140,13 +140,13 @@ public: GeoNear2DSphereStage(const GeoNearParams& nearParams, ExpressionContext* expCtx, WorkingSet* workingSet, - const Collection* collection, + const CollectionPtr& collection, const IndexDescriptor* s2Index); protected: std::unique_ptr<CoveredInterval> nextInterval(OperationContext* opCtx, WorkingSet* workingSet, - const Collection* collection) final; + const CollectionPtr& collection) final; double computeDistance(WorkingSetMember* member) final; @@ -158,7 +158,7 @@ private: // Estimate the density of data by search the nearest cells level by level around center. class DensityEstimator { public: - DensityEstimator(const Collection* collection, + DensityEstimator(const CollectionPtr& collection, PlanStage::Children* children, const GeoNearParams* nearParams, const S2IndexingParams& indexParams, @@ -177,7 +177,7 @@ private: WorkingSet* workingSet, const IndexDescriptor* s2Index); - const Collection* _collection; + const CollectionPtr& _collection; PlanStage::Children* _children; // Points to PlanStage::_children in the NearStage. const GeoNearParams* _nearParams; // Not owned here. const S2IndexingParams _indexParams; |