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

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

    • Type: Icon: Task Task
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 8.1.0-rc0
    • Affects Version/s: None
    • Component/s: None
    • RSS Sydney
    • Fully Compatible
    • GregsList - 2024-09-03, PopcornChicken - 2024-09-17

      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@mongodb.com Aaron Balsara
            Reporter:
            george.wangensteen@mongodb.com George Wangensteen
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: