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

    • Task
    • Status: Closed
    • Major - P3
    • Resolution: Fixed
    • None
    • 5.0.0-rc3, 5.1.0-rc0
    • None
    • None
    • Fully Compatible
    • v5.0
    • Execution Team 2021-06-28
    • 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

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

            Dates

              Created:
              Updated:
              Resolved: