summaryrefslogtreecommitdiff
path: root/src/mongo/db/catalog/drop_indexes.cpp
diff options
context:
space:
mode:
authorGeert Bosch <geert@mongodb.com>2019-02-14 09:50:31 -0500
committerGeert Bosch <geert@mongodb.com>2019-04-16 18:18:21 -0400
commit8914838187ee4124ce5512093109f457d23281b6 (patch)
treee38a62584e9ae042ae2e186d95d524be76a26313 /src/mongo/db/catalog/drop_indexes.cpp
parenta9f798957c907ec118a635ff4a0cc9a1a55c7114 (diff)
downloadmongo-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.cpp8
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);