movePrimary can cause unavailability of a database due to multi-document transactions

    • Type: Bug
    • Resolution: Unresolved
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • Catalog and Routing
    • ALL
    • 🟦 Shard Catalog
    • None
    • None
    • None
    • None
    • None
    • None

      As part of enabling SERVER-127622 we discovered that movePrimary can become blocked and cause a complete unavailability of the database if a multi-document transaction is present.

      This happens due to the following sequence of events:

      • A multi-document transaction starts on database A and targets collection B.
      • The transaction acquires a MODE_IX lock on both the database and the collection.
      • movePrimary is triggered, this attempts to take a MODE_X lock on the database. Crucially this means that all subsequent new MODE_IX acquisitions will wait.

      At this point the multi-document transaction is delaying all new locking accesses to the entire database, including sharded collections that would be unaffected by the movePrimary. This will only get resolved if the transaction commits or aborts whether by the user or due to the timeout of transactions.

            Assignee:
            Unassigned
            Reporter:
            Jordi Olivares Provencio
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: