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

Resolve lock-order-inversion TSAN error in TimestampKVEngineTest

    • Type: Icon: Task Task
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 8.0.0-rc0, 5.0.27, 7.0.9, 7.3.2, 6.0.16
    • Affects Version/s: None
    • Component/s: None
    • None
    • Storage Execution
    • Fully Compatible
    • v7.3, v7.0, v6.0, v5.0
    • Execution Team 2024-03-18, Execution Team 2024-04-01
    • 15

      Based on my understanding, it looks like the lock cycle is happening because of the following set up:

      On one thread, the `_monitorMutex`  mutex is taken here before calling notify(), and then the `mutex` mutex (defined here) is being taken here when we actually enter the listener and call notify.

      On another thread, we take the `mutex` mutex here, and then with that mutex still in scope we take the `_monitorMutex` here inside the call to removeListener here

      Meaning, we have a lock inversion order: `_monitorMutex` -> `mutex` on one thread, and `mutex` -> `_monitorMutex` on another.

      This can be resolved by wrapping up this acquisition of the `mutex` mutex inside an anonymous namespace, so that after we have waited on the listeners all changing the conditioned_variable the mutex goes out of scope, allowing us to call removeListener without a cycle.

            Assignee:
            damian.wasilewicz@mongodb.com Damian Wasilewicz
            Reporter:
            damian.wasilewicz@mongodb.com Damian Wasilewicz
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: