-
Notifications
You must be signed in to change notification settings - Fork 751
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
fix: MetaGrpcClient deadlock when drop #16727
fix: MetaGrpcClient deadlock when drop #16727
Conversation
939bdaa
to
dfc361d
Compare
5fb20f8
to
21ffe80
Compare
Move the reference to the dedicated runtime `rt` from `MetaGrpcClient` to `ClientHandle`. `rt` is a reference to the dedicated runtime for running `MetaGrpcClient`. If all ClientHandle are dropped, the runtime will be destroyed. This `rt` previously is stored in `MetaGrpcClient`, which leads to a deadlock: - When all `ClientHandle` are dropped, the two workers `worker_loop()` and `auto_sync_interval()` will quit. - These two futures both held a reference to `MetaGrpcClient`. - The last of these(say, `F`) two will drop `MetaGrpcClient.rt` and `Runtime::_dropper` will block waiting for the runtime to shut down. - But `F` is still held, deadlock occurs. Other changes: - `Runtime::try_spawn` and several other spawn methods now accept a name argument for display in async backtrace. - Add async-backtrace to `MetaGrpcClient` methods
21ffe80
to
cab7489
Compare
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.
Thank you @drmingdrmer for working on this!
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.
Reviewed 12 of 12 files at r1.
Reviewable status: 8 of 12 files reviewed, all discussions resolved (waiting on @everpcpc)
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.
Reviewed 1 of 1 files at r2, 3 of 3 files at r3, all commit messages.
Reviewable status: complete! all files reviewed, all discussions resolved (waiting on @everpcpc and @Xuanwo)
I hereby agree to the terms of the CLA available at: https://docs.databend.com/dev/policies/cla/
Summary
fix: MetaGrpcClient deadlock when drop
Move the reference to the dedicated runtime
rt
fromMetaGrpcClient
to
ClientHandle
.rt
is a reference to the dedicated runtime for runningMetaGrpcClient
.If all ClientHandle are dropped, the runtime will be destroyed.
This
rt
previously is stored inMetaGrpcClient
, which leads to a deadlock:ClientHandle
are dropped, the two workersworker_loop()
andauto_sync_interval()
will quit.
MetaGrpcClient
.F
) two will dropMetaGrpcClient.rt
andRuntime::_dropper
will block waiting for the runtime to shut down.
F
is still held, deadlock occurs.Other changes:
Runtime::try_spawn
and several other spawn methods now accept a nameargument for display in async backtrace.
Add async-backtrace to
MetaGrpcClient
methodsTests
Type of change
Related Issues
This change is