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

renameCollection target should never have identical UUID with a different database

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.6.4, 3.7.3
    • Component/s: Storage
    • Labels:
      None
    • Backwards Compatibility:
      Fully Compatible
    • Backport Requested:
      v3.6
    • Sprint:
      Storage 2018-02-12, Storage 2018-02-26
    • Linked BF Score:
      0

      Description

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

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                Created:
                Updated:
                Resolved: