summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Milkie <milkie@10gen.com>2020-07-20 12:55:13 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-07-23 18:16:34 +0000
commit475fcc6ebd04767fbbbe3231c516e70b9be7d90e (patch)
tree848a76b359e6439c68c802c109a2bed1f5fd082d
parent6e554668a820530cdf79360e4be1851e4cde2905 (diff)
downloadmongo-475fcc6ebd04767fbbbe3231c516e70b9be7d90e.tar.gz
SERVER-48428 do not acquire IX locks in createIndexes if not doing any writes; this will avoid it being killed by stepDown
-rw-r--r--src/mongo/db/commands/create_indexes.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/mongo/db/commands/create_indexes.cpp b/src/mongo/db/commands/create_indexes.cpp
index abcf15f4681..5794fb26436 100644
--- a/src/mongo/db/commands/create_indexes.cpp
+++ b/src/mongo/db/commands/create_indexes.cpp
@@ -510,7 +510,7 @@ bool runCreateIndexesWithCoordinator(OperationContext* opCtx,
// 3) Check if we can create the index without handing control to the IndexBuildsCoordinator.
OptionalCollectionUUID collectionUUID;
{
- Lock::DBLock dbLock(opCtx, ns.db(), MODE_IX);
+ Lock::DBLock dbLock(opCtx, ns.db(), MODE_IS);
checkDatabaseShardingState(opCtx, ns);
if (!repl::ReplicationCoordinator::get(opCtx)->canAcceptWritesFor(opCtx, ns)) {
uasserted(ErrorCodes::NotMaster,
@@ -518,12 +518,14 @@ bool runCreateIndexesWithCoordinator(OperationContext* opCtx,
}
bool indexExists = writeConflictRetry(opCtx, "createCollectionWithIndexes", ns.ns(), [&] {
- AutoGetCollection autoColl(opCtx, ns, MODE_IX);
+ AutoGetCollection autoColl(opCtx, ns, MODE_IS);
auto collection = autoColl.getCollection();
// Before potentially taking an exclusive collection lock, check if all indexes already
// exist while holding an intent lock.
if (collection && indexesAlreadyExist(opCtx, collection, specs, &result)) {
+ repl::ReplClientInfo::forClient(opCtx->getClient())
+ .setLastOpToSystemLastOpTime(opCtx);
return true;
}