summaryrefslogtreecommitdiff
path: root/src/mongo/db/catalog/database_impl.h
diff options
context:
space:
mode:
authorDaniel Gottlieb <daniel.gottlieb@mongodb.com>2019-09-16 18:33:28 +0000
committerevergreen <evergreen@mongodb.com>2019-09-16 18:33:28 +0000
commit8357a1d76883e8a20c014c58c6b1feabffb91742 (patch)
treecef46727cdadef8a5f15eb42c7980b362336d77b /src/mongo/db/catalog/database_impl.h
parent9c15f7ff0f43d0813aec101135800d285a0cb54b (diff)
downloadmongo-8357a1d76883e8a20c014c58c6b1feabffb91742.tar.gz
SERVER-42478: Relax create collection in oplog application to take a DB_IX lock.
Diffstat (limited to 'src/mongo/db/catalog/database_impl.h')
-rw-r--r--src/mongo/db/catalog/database_impl.h15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/mongo/db/catalog/database_impl.h b/src/mongo/db/catalog/database_impl.h
index da4b567e91f..fc34e401fd6 100644
--- a/src/mongo/db/catalog/database_impl.h
+++ b/src/mongo/db/catalog/database_impl.h
@@ -119,6 +119,16 @@ public:
return _viewsName;
}
+ /**
+ * Given an input pattern `collectionNameModel`, returns a namespace string where `%` characters
+ * are replaced with random alpha-numerics.
+ *
+ * When called while holding an exclusive database lock, the collection name is guaranteed to
+ * not exist. Otherwise the caller is responsible for acquiring locks to check uniqueness.
+ *
+ * Returns a NamespaceExists error status if multiple attempts fail to generate a possible
+ * unique name.
+ */
StatusWith<NamespaceString> makeUniqueCollectionNamespace(OperationContext* opCtx,
StringData collectionNameModel) final;
@@ -176,9 +186,8 @@ private:
AtomicWord<bool> _dropPending{false};
// Random number generator used to create unique collection namespaces suitable for temporary
- // collections. Lazily created on first call to makeUniqueCollectionNamespace().
- // This variable may only be read/written while the database is locked in MODE_X.
- std::unique_ptr<PseudoRandom> _uniqueCollectionNamespacePseudoRandom;
+ // collections.
+ PseudoRandom _uniqueCollectionNamespacePseudoRandom;
};
} // namespace mongo