diff options
author | Dianna Hohensee <dianna.hohensee@mongodb.com> | 2022-07-25 16:52:52 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-07-25 17:32:28 +0000 |
commit | c808bc35dfe537a68961ec0fdfa5864793d550d7 (patch) | |
tree | 9c682ebb1e3fb3f312e25c6a300afeec2f49cf3c /src/mongo | |
parent | 4b16e0d00a54e18f7b6bcb2a999ebee6c1e49ea5 (diff) | |
download | mongo-c808bc35dfe537a68961ec0fdfa5864793d550d7.tar.gz |
SERVER-68199 Rename collection must check for index builds on the target collection before specially dropping indexes with names that are too long
Diffstat (limited to 'src/mongo')
-rw-r--r-- | src/mongo/db/catalog/rename_collection.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/mongo/db/catalog/rename_collection.cpp b/src/mongo/db/catalog/rename_collection.cpp index 4d8f7769a7d..d4fefd2c28b 100644 --- a/src/mongo/db/catalog/rename_collection.cpp +++ b/src/mongo/db/catalog/rename_collection.cpp @@ -274,6 +274,12 @@ Status renameCollectionAndDropTarget(OperationContext* opCtx, // Target collection exists - drop it. invariant(options.dropTarget); + // Check for index builds on the target collection before dropping any indexes or the + // collection. + BackgroundOperation::assertNoBgOpInProgForNs(targetColl->ns().ns()); + IndexBuildsCoordinator::get(opCtx)->assertNoIndexBuildInProgForCollection( + targetColl->uuid().get()); + // If this rename collection is replicated, check for long index names in the target // collection that may exceed the MMAPv1 namespace limit when the target collection // is renamed with a drop-pending namespace. @@ -305,10 +311,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().get()); - auto status = db->dropCollection(opCtx, targetColl->ns(), renameOpTime); if (!status.isOK()) return status; |