Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-33086

renameCollection target should never have identical UUID with a different database

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 3.6.4, 3.7.3
    • Affects Version/s: None
    • Component/s: Storage
    • None
    • Fully Compatible
    • v3.6
    • Storage 2018-02-12, Storage 2018-02-26
    • 0

      From: https://github.com/mongodb/mongo/blob/69f920a868112a059f6c09f373f9fb93a1b6b0e5/src/mongo/db/catalog/rename_collection.cpp#L141-L157

      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);
              }
      

            Assignee:
            xiangyu.yao@mongodb.com Xiangyu Yao (Inactive)
            Reporter:
            judah.schvimer@mongodb.com Judah Schvimer
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: