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

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

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Won't Do
    • Icon: Major - P3 Major - P3
    • None
    • None
    • None
    • None
    • ALL
    • 131

    Description

      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.

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: