fix(executor): support destruction from worker threads - #233
Merged
lxy-9602 merged 1 commit intoAug 28, 2026
Merged
Conversation
mrdrivingduck
force-pushed
the
codex/fix_default_executor_shutdown
branch
from
August 21, 2026 06:04
29b72fb to
9d7ba65
Compare
mrdrivingduck
marked this pull request as ready for review
August 21, 2026 07:00
mrdrivingduck
force-pushed
the
codex/fix_default_executor_shutdown
branch
5 times, most recently
from
August 25, 2026 11:51
71f6a98 to
bbd4a84
Compare
Collaborator
|
Thanks for your contribution. The core fix is correct and effective. Moving the scheduling state into a shared_ptr so that workers never touch this, combined with detach() when the thread being shut down is the current one, is the right approach — both parts are necessary, since detaching without relocating the state would leave the surviving worker touching freed members. |
lucasfang
reviewed
Aug 26, 2026
Decouple worker state from the executor object so that a task can safely destroy its final executor owner from a worker thread. Serialize shutdown so concurrent callers cannot attempt to join the same worker. Co-authored-by: GPT-5.6 Terra <codex@users.noreply.github.com>
mrdrivingduck
force-pushed
the
codex/fix_default_executor_shutdown
branch
from
August 27, 2026 16:57
bbd4a84 to
e6f4fce
Compare
Collaborator
|
+1 |
lxy-9602
approved these changes
Aug 28, 2026
lxy-9602
left a comment
Member
There was a problem hiding this comment.
+1 Thank you for your patience!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
While testing the OSS filesystem asynchronous read path, we found a lifecycle issue in
DefaultExecutor. The issue is not OSS-specific: S3 asynchronous reads use the same ownership pattern and can trigger it as well.The sequence is:
shared_ptrto its client.join()the current worker thread.Without this fix, joining the current thread throws
std::system_errorwithResource deadlock avoided. Since this happens during destruction, it can terminate the process.This PR separates the executor's shared scheduling state from the executor object. Workers retain the shared state rather than accessing the executor through
this. When destruction happens on a worker, shutdown stops the shared state, joins the other workers, and detaches the current one. The current worker then finishes its task and exits normally.The PR adds a generic executor regression test and an S3 asynchronous range-read test covering this lifecycle.