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

Block AsioReactor::drain until all tasks have been completed

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • Server Programmability
    • Networking & Obs 2024-09-16

      The implementation of AsioReactor::drain currently runs poll() in a loop until it returns false, which indicates there are no ready handlers (there may still be unready ones, however). It then sets a flag that will cause schedule() calls to fail and runs the loop again. This nonstandard draining was put in place to reduce the likliehood of the crashes fixed in SERVER-92134. It has the side effect of possibly not draining tasks which are taking a long time, however.

      Once SERVER-92134 is merged, AsioReactor::drain can be changed to block until draining has fully completed. This will involve setting the flag that causes scheduling new tasks to fail immediately, and then using run() rather than poll(), which provides the desired blocking behavior.

      https://live.boost.org/doc/libs/1_84_0/doc/html/boost_asio/reference/io_context/run/overload1.html

            Assignee:
            Unassigned Unassigned
            Reporter:
            patrick.freed@mongodb.com Patrick Freed
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: