diff options
author | Dianna Hohensee <dianna.hohensee@mongodb.com> | 2020-10-05 13:11:19 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-10-08 08:45:03 +0000 |
commit | ca0150eaf6cad95debae550c28fd50bb016db396 (patch) | |
tree | bc37490d499c2ada761a9ac2485ce8027fec5d10 /src/mongo/db/catalog/database_holder.h | |
parent | 1f11a9c73e11ebb6a89b1600a0a03741111c48bc (diff) | |
download | mongo-ca0150eaf6cad95debae550c28fd50bb016db396.tar.gz |
SERVER-50678 Implement lock-free version of AutoGetCollection
Diffstat (limited to 'src/mongo/db/catalog/database_holder.h')
-rw-r--r-- | src/mongo/db/catalog/database_holder.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/mongo/db/catalog/database_holder.h b/src/mongo/db/catalog/database_holder.h index 890ad037de1..32e422b2e0c 100644 --- a/src/mongo/db/catalog/database_holder.h +++ b/src/mongo/db/catalog/database_holder.h @@ -42,6 +42,7 @@ class CollectionCatalogEntry; class Database; class OperationContext; class RecordStore; +class ViewCatalog; /** * Registry of opened databases. @@ -65,6 +66,18 @@ public: virtual Database* getDb(OperationContext* const opCtx, const StringData ns) const = 0; /** + * Fetches the ViewCatalog decorating the Database matching 'dbName', or returns nullptr if the + * database does not exist. The returned ViewCatalog is safe to access without a lock because it + * is held as a shared_ptr. + * + * The ViewCatalog must be fetched through this interface if the caller holds no database lock + * to ensure the Database object is safe to access. This class' internal mutex provides + * concurrency protection around looking up and accessing the Database object matching 'dbName. + */ + virtual std::shared_ptr<ViewCatalog> getSharedViewCatalog(OperationContext* const opCtx, + StringData dbName) const = 0; + + /** * Retrieves a database reference if it is already opened, or opens it if it hasn't been * opened/created yet. Must be called with the database locked in X-mode. * |