-
Type: Improvement
-
Resolution: Unresolved
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
-
Networking & Observability
-
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