Avoid storing `opCtx` pointers inside instances of `RecoveryUnit`

    • Type: Bug
    • Resolution: Unresolved
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • Storage Engines - Server Integration
    • ALL
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      This creates a circular lifetime dependency that is not enforced, thus allowing read-after-write / use-after-free data races, especially during process termination. For example, running the shutdownTask on a shard server will result in rolling back stashed transactions – this may cause using opCtx pointers stored on instances of RecoveryUnit, while the actual opCtx might have been deleted already.

      My recommendation is to avoid storing opCtx pointers in RecoveryUnit. Instead, we should have its public APIs expect a pointer to opCtx if needed, or store pointers to objects that will always outlive any instance of RecoveryUnit.

            Assignee:
            Unassigned
            Reporter:
            Amirsaman Memaripour
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: