From b3305c20f8505648460fcbb177fff21c9c1cf3d0 Mon Sep 17 00:00:00 2001 From: Pavi Vetriselvan Date: Thu, 21 Jul 2022 18:31:09 +0000 Subject: SERVER-61481 Remove check in dropIndexes that no index builds are in progress for coll --- src/mongo/db/catalog/drop_indexes.cpp | 17 ----------- src/mongo/db/repl/oplog.cpp | 54 ++++++----------------------------- 2 files changed, 9 insertions(+), 62 deletions(-) diff --git a/src/mongo/db/catalog/drop_indexes.cpp b/src/mongo/db/catalog/drop_indexes.cpp index 54d3ffd1408..cce44ba1869 100644 --- a/src/mongo/db/catalog/drop_indexes.cpp +++ b/src/mongo/db/catalog/drop_indexes.cpp @@ -560,15 +560,6 @@ DropIndexesReply dropIndexes(OperationContext* opCtx, invariant((*collection)->getIndexCatalog()->numIndexesInProgress(opCtx) == 0); } - // TODO(SERVER-61481): Remove this block once kLastLTS is 6.0. As of 5.2, dropping an index - // while having a separate index build on the same collection is permitted. - if (serverGlobalParams.featureCompatibility.isLessThan( - multiversion::FeatureCompatibilityVersion::kVersion_5_2)) { - // The index catalog requires that no active index builders are running when dropping ready - // indexes. - IndexBuildsCoordinator::get(opCtx)->assertNoIndexBuildInProgForCollection(collectionUUID); - } - writeConflictRetry( opCtx, "dropIndexes", dbAndUUID.toString(), [opCtx, &collection, &indexNames, &reply] { WriteUnitOfWork wunit(opCtx); @@ -607,14 +598,6 @@ Status dropIndexesForApplyOps(OperationContext* opCtx, "indexes"_attr = cmdObj[kIndexFieldName].toString(false)); } - // TODO(SERVER-61481): Remove this block once kLastLTS is 6.0. As of 5.2, dropping an index - // while having a separate index build on the same collection is permitted. - if (serverGlobalParams.featureCompatibility.isLessThan( - multiversion::FeatureCompatibilityVersion::kVersion_5_2)) { - IndexBuildsCoordinator::get(opCtx)->assertNoIndexBuildInProgForCollection( - collection->uuid()); - } - auto swIndexNames = getIndexNames(opCtx, collection.getCollection(), parsed.getIndex()); if (!swIndexNames.isOK()) { return swIndexNames.getStatus(); diff --git a/src/mongo/db/repl/oplog.cpp b/src/mongo/db/repl/oplog.cpp index b67acd0c653..f638e4f1599 100644 --- a/src/mongo/db/repl/oplog.cpp +++ b/src/mongo/db/repl/oplog.cpp @@ -1964,51 +1964,15 @@ Status applyCommand_inlock(OperationContext* opCtx, auto ns = cmd->parse(opCtx, OpMsgRequest::fromDBAndBody(nss.db(), o))->ns(); - // TODO (SERVER-61481): Once kLastLTS is 6.0, this error will only be possible in - // mode kInitialSync. - if (mode == OplogApplication::Mode::kInitialSync) { - abortIndexBuilds(opCtx, - entry.getCommandType(), - ns, - "Aborting index builds during initial sync"); - LOGV2_DEBUG(4665901, - 1, - "Conflicting DDL operation encountered during initial sync; " - "aborting index build and retrying", - logAttrs(ns)); - } else { - auto lockState = opCtx->lockState(); - Locker::LockSnapshot lockSnapshot; - auto locksReleased = lockState->saveLockStateAndUnlock(&lockSnapshot); - - ScopeGuard guard{[&] { - if (locksReleased) { - invariant(!lockState->isLocked()); - lockState->restoreLockState(lockSnapshot); - } - }}; - - auto swUUID = entry.getUuid(); - if (!swUUID) { - LOGV2_ERROR(21261, - "Failed command during oplog application. Expected a UUID", - "command"_attr = redact(o), - logAttrs(ns)); - } - IndexBuildsCoordinator::get(opCtx)->awaitNoIndexBuildInProgressForCollection( - opCtx, swUUID.get()); - - opCtx->recoveryUnit()->abandonSnapshot(); - opCtx->checkForInterrupt(); - - LOGV2_DEBUG( - 51775, - 1, - "Acceptable error during oplog application: background operation in " - "progress for namespace", - logAttrs(ns), - "oplogEntry"_attr = redact(entry.toBSONForLogging())); - } + // This error is only possible during initial sync mode. + invariant(mode == OplogApplication::Mode::kInitialSync); + abortIndexBuilds( + opCtx, entry.getCommandType(), ns, "Aborting index builds during initial sync"); + LOGV2_DEBUG(4665901, + 1, + "Conflicting DDL operation encountered during initial sync; " + "aborting index build and retrying", + logAttrs(ns)); break; } -- cgit v1.2.1