The targetUUID here is actually the source collection's UUID, and we're checking if the target collection has the same UUID as the source collection. In that case it should be impossible for the databases to be different. We should change this to an assertion if this isn't true.
// Check if the target namespace exists and if dropTarget is true. // Return a non-OK status if target exists and dropTarget is not true or if the collection // is sharded. Collection* targetColl = targetDB->getCollection(opCtx, target); if (targetColl) { // If we already have the collection with the target UUID, we found our future selves, // so nothing left to do but drop the source collection in case of cross-db renames. if (targetUUID && targetUUID == targetColl->uuid()) { if (source.db() == target.db()) return Status::OK(); BSONObjBuilder unusedResult; return dropCollection(opCtx, source, unusedResult, {}, DropCollectionSystemCollectionMode::kAllowSystemCollectionDrops); }
- related to
-
SERVER-33087 Fix the use of dropTarget in renameCollection
- Closed