Lock order inversion in WiredTigerKVEngine::beginNonBlockingBackup and WiredTigerKVEngine::endNonBlockingBackup

XMLWordPrintableJSON

    • Type: Task
    • Resolution: Fixed
    • Priority: Major - P3
    • 8.1.0-rc0
    • Affects Version/s: None
    • Component/s: None
    • Storage Engines - Server Integration
    • Fully Compatible
    • GregsList - 2024-09-03, PopcornChicken - 2024-09-17
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      WiredTigerKVEngine::beginNonBlockingBackup acquires _oplogPinnedByBackupMutex before acquiring _wtBackup.wtBackupDupCursorMutex (see here).

      But WiredTigerKVEngine::endNonBlockingBackup acquires these mutexes in the inverted order: https://github.com/10gen/mongo/blob/16f711ffff54f0cf019efda3dc7796c39f7fe615/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp#L1365-L1369.

      Both of these functions acquire _wtBackup.wtBackupCursorMutex first/before either of these mutexes, so there isn't a real deadlock today. But it makes the code hard to reason about, bug-prone in the future, and requires a TSAN suppression to run without these locks having a clear ordering.

              Assignee:
              Aaron Balsara
              Reporter:
              George Wangensteen (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Created:
                Updated:
                Resolved: