Coverity: fix async continuation races in FileCopyBasedInitialSyncer

    • Type: Task
    • Resolution: Unresolved
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Replication
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      What

      Snapshot locked state (cancellation token, sync-source) into a local variable under the lock before entering `.then()` / `AsyncTry` continuation chains, so the lambda captures the local rather than accessing `this->_member` after the lock has been released.

      Files: `file_copy_based_initial_syncer.cpp` (lines 273, 274, 756, 917, 1167), `primary_only_service_util.cpp` (line 64).

      Resolves: SERVER-108529, SERVER-108530, SERVER-108705, SERVER-108720, SERVER-108731, SERVER-114658, SERVER-111263

      Why

      Once `.then()` is scheduled, the enclosing stack unwinds and the original lock is no longer held when the lambda executes. Snapshotting before the chain boundary closes the race structurally — the lambda no longer needs the lock because it holds an immutable local copy. Because Coverity cannot be run locally, the snapshot pattern is also self-documenting proof that the fix is correct.

            Assignee:
            Unassigned
            Reporter:
            Denis Trailin
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: