diff options
author | Mindaugas Malinauskas <mindaugas.malinauskas@mongodb.com> | 2023-04-12 10:27:13 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2023-04-12 11:06:27 +0000 |
commit | ed0d55f7e8686c7c71fe113554e7e2782d7ea6d8 (patch) | |
tree | ff325fdcf9bd26e86cfd78f8d483f41d46d77183 /src/mongo/db/catalog/create_collection.cpp | |
parent | e72720dda5265d438837d8d6028c665f7bbe6c58 (diff) | |
download | mongo-ed0d55f7e8686c7c71fe113554e7e2782d7ea6d8.tar.gz |
SERVER-66715 Add tenant lock
Diffstat (limited to 'src/mongo/db/catalog/create_collection.cpp')
-rw-r--r-- | src/mongo/db/catalog/create_collection.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/mongo/db/catalog/create_collection.cpp b/src/mongo/db/catalog/create_collection.cpp index 2707a8457b2..4ba2d7ad358 100644 --- a/src/mongo/db/catalog/create_collection.cpp +++ b/src/mongo/db/catalog/create_collection.cpp @@ -546,7 +546,12 @@ Status _createCollection( const boost::optional<BSONObj>& idIndex, const boost::optional<VirtualCollectionOptions>& virtualCollectionOptions = boost::none) { return writeConflictRetry(opCtx, "create", nss.ns(), [&] { - AutoGetDb autoDb(opCtx, nss.dbName(), MODE_IX); + // If a change collection is to be created, that is, the change streams are being enabled + // for a tenant, acquire exclusive tenant lock. + AutoGetDb autoDb(opCtx, + nss.dbName(), + MODE_IX /* database lock mode*/, + boost::make_optional(nss.tenantId() && nss.isChangeCollection(), MODE_X)); Lock::CollectionLock collLock(opCtx, nss, MODE_IX); auto db = autoDb.ensureDbExists(opCtx); |