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

Don't hold the Fetcher::_mutex while emplacing the completion promise

    • Type: Icon: Bug Bug
    • Resolution: Won't Do
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None
    • ALL
    • 131

      We must ensure that a Fetcher may be immediately destroyed after emplacing a value in the Fetcher::_completionPromise. This prevents deadlock since the Fetcher destructor calls shutdown which also acquires the Fetcher::_mutex.

      Consider the following snippet:

      {
        auto fetcher = makeFetcherSharedPointer(...);
        fetcher.onCompletion().thenRunOn(executorWhichRejectsWork).then([fetcher] {
          // this will never run
        });
      }
      

      An executor which rejects work (likely due to being shutdown) will never run the completion, and so the fetcher destructor will be run inline with the fulfillment of the future.

            Assignee:
            matt.broadstone@mongodb.com Matt Broadstone
            Reporter:
            matt.broadstone@mongodb.com Matt Broadstone
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: