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

Rename with dropTarget must be done atomically in the catalog to prevent a lock free reader to observe intermediate invalid state

    XMLWordPrintableJSON

Details

    • Icon: Task Task
    • Resolution: Fixed
    • Icon: Major - P3 Major - P3
    • 4.9.0
    • None
    • None
    • None
    • Fully Compatible
    • Execution Team 2021-01-11
    • 50

    Description

      Rename with dropTarget=true is performed in two phases with each phase is writing to the catalog while holding a MODE_X lock for the collection.

      https://github.com/mongodb/mongo/blob/72565dc7c6909fd6f96f5625a9d28c64efed8c9e/src/mongo/db/catalog/rename_collection.cpp#L267-L273

      As holding a MODE_X lock does not prevent a lock free reader it may observe the collection as dropped as this is written to the in-memory catalog separately from the rename: 

      https://github.com/mongodb/mongo/blob/72565dc7c6909fd6f96f5625a9d28c64efed8c9e/src/mongo/db/catalog/database_impl.cpp#L517-L522

      This whole operation must be performed atomically in a single catalog write as MODE_X lock mode cannot be used to prevent readers anymore.

      Attachments

        Activity

          People

            henrik.edin@mongodb.com Henrik Edin
            henrik.edin@mongodb.com Henrik Edin
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: