fix: defer EventLoopThread teardown off DbLoop to avoid self-join - #2556
Open
wangshuo-wsws wants to merge 5 commits into
Open
fix: defer EventLoopThread teardown off DbLoop to avoid self-join#2556wangshuo-wsws wants to merge 5 commits into
wangshuo-wsws wants to merge 5 commits into
Conversation
added 5 commits
August 14, 2026 18:58
Signed-off-by: harleywilsoneng <harleywilsoneng@users.noreply.github.com>
Signed-off-by: harleywilsoneng <harleywilsoneng@users.noreply.github.com>
Signed-off-by: harleywilsoneng <harleywilsoneng@users.noreply.github.com>
Signed-off-by: harleywilsoneng <harleywilsoneng@users.noreply.github.com>
Signed-off-by: harleywilsoneng <harleywilsoneng@users.noreply.github.com>
Member
|
@harleywilsoneng Thanks so much for your patch. I've made a PR an-tao/trantor#408 for that issue, please check it out. |
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.
Summary
Fixes
std::system_error/ “Resource deadlock avoided” when the lastDbClient/ SQLite connection /PgListenerreference is released from inside its ownEventLoopThreadcallback (#2552).~EventLoopThreadcallsthread_.join(). If that destructor runs on the same worker thread (via a completion lambda holding the lastshared_ptr),join()throws and the process aborts.EventLoopThread/EventLoopThreadPoolso ownership can be moved off the loop threadisInLoopThread(), hand the handle to a short-lived helper thread that performs the real teardown andjoin()Touches
DbClientImpl,Sqlite3Connection, andPgListener(same hazard on each).Test plan
:memory:reproducer from EventLoopThread self-join in DbClientImpl teardown when last ref released from own DbLoop thread (throws Resource deadlock avoided) #2552 in a loop; process should no longer abortDbClientconstruct /execSql/ destroy from a non-loop thread still worksCloses #2552