Harden AsyncWorkScheduler remote-command scheduling

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Fixed
    • Priority: Major - P3
    • 9.1.0-rc0, 9.0.0-rc3
    • Affects Version/s: None
    • Component/s: None
    • None
    • Replication
    • Fully Compatible
    • ALL
    • v9.0
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Follow-ups from SERVER-131575 (AsyncWorkScheduler use-after-free fix)

      1. Remove unsafeToInlineFuture() from the targeting chain. scheduleRemoteCommand targets via findHost().thenRunOn(_executor).unsafeToInlineFuture().then(...). It works because thenRunOn(_executor) re-anchors delivery, but unsafeToInlineFuture() is a sharp tool and the continuation's thread isn't guaranteed. Rework the targeting/send chain to stay an ExecutorFuture end-to-end.
      2. Anchor the executor through the continuation chain. Capture getExecutor() down the scheduleRemoteCommand continuations so the executor object is guaranteed to outlive them (per samanca's review suggestion).
      3. Re-evaluate/document holding _mutex across _executor->schedule() calls.* Vetted safe for ThreadPoolTaskExecutor (it refuses with ShutdownInProgress rather than running the callback inline), but it's fragile if the executor implementation changes; either stop holding the lock across the schedule call or document the invariant.
      4. (Optional) Note the GuaranteedExecutor::enforceRunOnce invariant-on-pool-reject race for completeness.

      Consider backporting alongside SERVER-131575 where the same code exists.

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

              Created:
              Updated:
              Resolved: