diff options
author | Geert Bosch <geert@mongodb.com> | 2019-02-14 09:50:31 -0500 |
---|---|---|
committer | Geert Bosch <geert@mongodb.com> | 2019-04-16 18:18:21 -0400 |
commit | 8914838187ee4124ce5512093109f457d23281b6 (patch) | |
tree | e38a62584e9ae042ae2e186d95d524be76a26313 /src/mongo/db/catalog/drop_indexes.cpp | |
parent | a9f798957c907ec118a635ff4a0cc9a1a55c7114 (diff) | |
download | mongo-8914838187ee4124ce5512093109f457d23281b6.tar.gz |
SERVER-39517 Only use Collection MODE_X for index creation and drop
Diffstat (limited to 'src/mongo/db/catalog/drop_indexes.cpp')
-rw-r--r-- | src/mongo/db/catalog/drop_indexes.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/mongo/db/catalog/drop_indexes.cpp b/src/mongo/db/catalog/drop_indexes.cpp index 56143447308..ef6074eaaff 100644 --- a/src/mongo/db/catalog/drop_indexes.cpp +++ b/src/mongo/db/catalog/drop_indexes.cpp @@ -200,7 +200,7 @@ Status dropIndexes(OperationContext* opCtx, const BSONObj& cmdObj, BSONObjBuilder* result) { return writeConflictRetry(opCtx, "dropIndexes", nss.db(), [opCtx, &nss, &cmdObj, result] { - AutoGetDb autoDb(opCtx, nss.db(), MODE_X); + AutoGetCollection autoColl(opCtx, nss, MODE_IX, MODE_X); bool userInitiatedWritesAndNotPrimary = opCtx->writesAreReplicated() && !repl::ReplicationCoordinator::get(opCtx)->canAcceptWritesFor(opCtx, nss); @@ -215,9 +215,9 @@ Status dropIndexes(OperationContext* opCtx, } // If db/collection does not exist, short circuit and return. - Database* db = autoDb.getDb(); - Collection* collection = db ? db->getCollection(opCtx, nss) : nullptr; - if (!db || !collection) { + Database* db = autoColl.getDb(); + Collection* collection = autoColl.getCollection(); + if (!collection) { if (db && ViewCatalog::get(db)->lookup(opCtx, nss.ns())) { return Status(ErrorCodes::CommandNotSupportedOnView, str::stream() << "Cannot drop indexes on view " << nss); |