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

Dropping timeseries view and creating Collection on same namespace may be replicated out-of-order

    XMLWordPrintable

    Details

    • Type: Task
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 5.1.0, 5.0.0-rc3
    • Component/s: None
    • Labels:
      None
    • Backwards Compatibility:
      Fully Compatible
    • Backport Requested:
      v5.0
    • Sprint:
      Execution Team 2021-06-28
    • Linked BF Score:
      150

      Description

      When dropping a Timeseries collection we hold a MODE_X lock on the bucket collection but just a MODE_IX lock on the view namespace.

      _abortIndexBuildsAndDrop called here is holding a MODE_X lock on the bucket Collection:
      https://github.com/mongodb/mongo/blob/fd808e64b2a34bedfeeef012c2ef9314bec08e8f/src/mongo/db/catalog/drop_collection.cpp#L330

      But the View is just holding a MODE_IX lock
      https://github.com/mongodb/mongo/blob/fd808e64b2a34bedfeeef012c2ef9314bec08e8f/src/mongo/db/catalog/drop_collection.cpp#L91

      If there is a create Collection happening concurrently (also MODE_IX) with dropping the view the operations may be written to the oplog out-of-order because create Collection reserves the oplog time before creating the Collection: https://github.com/mongodb/mongo/blob/fd808e64b2a34bedfeeef012c2ef9314bec08e8f/src/mongo/db/catalog/database_impl.cpp#L679-L692

      When this is then applied on a secondary the Collection creation fails with an invariant because there already exist a timeseries view on the namespace.

      A proposed solution is to hold a MODE_X lock on the view namespace when dropping timeseries collections.

        Attachments

          Activity

            People

            Assignee:
            henrik.edin Henrik Edin
            Reporter:
            henrik.edin Henrik Edin
            Participants:
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: