-
Notifications
You must be signed in to change notification settings - Fork 412
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
disagg: Fix a potential crash when shutting down #8848
Conversation
/run-all-tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: CalvinNeo, JinheLin The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Meanwhile, I don't think it's a good idea to make a ThreadPool lives actually shorter than its tasks. |
In response to a cherrypick label: new pull request created to branch |
What problem does this PR solve?
Issue Number: close #8837
Problem Summary:
There is a logging about "std::exception. Code: 1001, type: std::__1::system_error, e.what() = thread::join failed: Resource deadlock avoided". Usually it is caused by a thread is trying to call
join
for the thread itself.There is a chance that the task handle (shared_ptr) is being held by the background pool thread
tiflash/dbms/src/Storages/BackgroundProcessingPool.cpp
Lines 226 to 228 in 0d13f39
And the task handle could hold a shared_ptr to
UniversalPageStorageService
. So there could be a chance that:UniversalPageStorageService::shutdown
is calledremote_checkpoint_handle
, which contains a shared_ptr ofUniversalPageStorageService
UniversalPageStorageService
in theContextShared
is releasedremote_checkpoint_handle
, which cause the shared_ptr ofUniversalPageStorageService
being released. But the thread is created byUniversalPageStorageService::checkpoint_pool
. So the thread run into callingjoin
on itself and causing the system_errorWhat is changed and how it works?
Use a
weak_ptr
ofUniversalPageStorageService
instead ofshared_ptr
. So that even when theremote_checkpoint_handle
is still holding by the background pool thread, it won't cause the background pool thread callingjoin
on itself. Because the share counter ofUniversalPageStorageService
must go down to 0 outside of the background pool thread.Check List
Tests
Side effects
Documentation
Release note