From c4c5768798b72027a7b40eb0bbf4455f7e9564b9 Mon Sep 17 00:00:00 2001 From: Gregory Wlodarek Date: Tue, 12 May 2020 13:58:45 -0400 Subject: SERVER-48152 renameCollectionAndDropTarget() should check for background operations before calling preRenameCollection() --- src/mongo/db/catalog/rename_collection.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/mongo/db/catalog/rename_collection.cpp b/src/mongo/db/catalog/rename_collection.cpp index d398b5eb188..24b9f9cbb6b 100644 --- a/src/mongo/db/catalog/rename_collection.cpp +++ b/src/mongo/db/catalog/rename_collection.cpp @@ -241,6 +241,10 @@ Status renameCollectionAndDropTarget(OperationContext* opCtx, invariant(renameOpTimeFromApplyOps.isNull()); } + BackgroundOperation::assertNoBgOpInProgForNs(targetColl->ns().ns()); + IndexBuildsCoordinator::get(opCtx)->assertNoIndexBuildInProgForCollection( + targetColl->uuid()); + auto numRecords = targetColl->numRecords(opCtx); auto opObserver = opCtx->getServiceContext()->getOpObserver(); auto renameOpTime = opObserver->preRenameCollection( @@ -264,10 +268,6 @@ Status renameCollectionAndDropTarget(OperationContext* opCtx, // No logOp necessary because the entire renameCollection command is one logOp. repl::UnreplicatedWritesBlock uwb(opCtx); - BackgroundOperation::assertNoBgOpInProgForNs(targetColl->ns().ns()); - IndexBuildsCoordinator::get(opCtx)->assertNoIndexBuildInProgForCollection( - targetColl->uuid()); - auto status = db->dropCollection(opCtx, targetColl->ns(), renameOpTime); if (!status.isOK()) return status; -- cgit v1.2.1