summaryrefslogtreecommitdiff
path: root/src/mongo/db/catalog/collection.h
diff options
context:
space:
mode:
authorHenrik Edin <henrik.edin@mongodb.com>2020-07-31 15:26:11 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-08-07 13:32:12 +0000
commit9de175fb3776415e7237e6c0af4b76f518adc451 (patch)
tree56a22e0f57be9937d53deed8f76fdbc2502639c3 /src/mongo/db/catalog/collection.h
parent21d5a8e5bd822e71e5fb8feb2f9e71a7e8cf25f9 (diff)
downloadmongo-9de175fb3776415e7237e6c0af4b76f518adc451.tar.gz
SERVER-47885 Added lookupCollectionByXXXForRead interface to the Collection catalog that returns collection as shared_ptr<const Collection>
AutoGetCollectionForRead and AutoGetCollectionForReadCommand now uses this and holds the shared_ptr. They return the collection as const. Const correct various places to make this possible. Moved some logic from Collection destructors to deregister from the catalog as they may now be destroyed at a later point.
Diffstat (limited to 'src/mongo/db/catalog/collection.h')
-rw-r--r--src/mongo/db/catalog/collection.h16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/mongo/db/catalog/collection.h b/src/mongo/db/catalog/collection.h
index 337e474e1dd..9b0d5f5b223 100644
--- a/src/mongo/db/catalog/collection.h
+++ b/src/mongo/db/catalog/collection.h
@@ -109,7 +109,7 @@ public:
/**
* Wakes up all threads waiting.
*/
- void notifyAll();
+ void notifyAll() const;
/**
* Waits until 'deadline', or until notifyAll() is called to indicate that new
@@ -147,7 +147,7 @@ private:
//
// The condition which '_cappedNewDataNotifier' is being notified of is an increment of this
// counter. Access to this counter is synchronized with '_mutex'.
- uint64_t _version = 0;
+ mutable uint64_t _version = 0;
// True once the notifier is dead.
bool _dead = false;
@@ -190,7 +190,7 @@ public:
* Constructs a Collection object. This does not persist any state to the storage engine,
* only constructs an in-memory representation of what already exists on disk.
*/
- virtual std::unique_ptr<Collection> make(OperationContext* opCtx,
+ virtual std::shared_ptr<Collection> make(OperationContext* opCtx,
const NamespaceString& nss,
RecordId catalogId,
CollectionUUID uuid,
@@ -490,6 +490,7 @@ public:
* The storage engine interacts with capped collections through a CappedCallback interface.
*/
virtual CappedCallback* getCappedCallback() = 0;
+ virtual const CappedCallback* getCappedCallback() const = 0;
/**
* Get a pointer to a capped insert notifier object. The caller can wait on this object
@@ -519,7 +520,7 @@ public:
* If return value is not boost::none, reads with majority read concern using an older snapshot
* must error.
*/
- virtual boost::optional<Timestamp> getMinimumVisibleSnapshot() = 0;
+ virtual boost::optional<Timestamp> getMinimumVisibleSnapshot() const = 0;
virtual void setMinimumVisibleSnapshot(const Timestamp name) = 0;
@@ -547,7 +548,7 @@ public:
virtual std::unique_ptr<PlanExecutor, PlanExecutor::Deleter> makePlanExecutor(
OperationContext* opCtx,
PlanYieldPolicy::YieldPolicy yieldPolicy,
- ScanDirection scanDirection) = 0;
+ ScanDirection scanDirection) const = 0;
virtual void indexBuildSuccess(OperationContext* opCtx, IndexCatalogEntry* index) = 0;
@@ -559,6 +560,11 @@ public:
*/
virtual void establishOplogCollectionForLogging(OperationContext* opCtx) = 0;
+ /**
+ * Called when this Collection is deregistered from the catalog
+ */
+ virtual void onDeregisterFromCatalog() = 0;
+
friend auto logAttrs(const Collection& col) {
return logv2::multipleAttrs(col.ns(), col.uuid());
}