-
Notifications
You must be signed in to change notification settings - Fork 111
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(panic): Stop panicking on async task cancellation on shutdown in network and state futures #7219
Merged
Conversation
This file contains 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
teor2345
added
C-bug
Category: This is a bug
P-Medium ⚡
I-panic
Zebra panics with an internal error message
I-usability
Zebra is hard to understand or use
A-network
Area: Network protocol updates or fixes
A-state
Area: State / database changes
A-concurrency
Area: Async code, needs extra work to make it work properly.
labels
Jul 17, 2023
arya2
previously approved these changes
Jul 17, 2023
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.
This looks great, thank you for the simplification!
Co-authored-by: Arya <[email protected]>
Co-authored-by: Arya <[email protected]>
arya2
approved these changes
Jul 17, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
A-concurrency
Area: Async code, needs extra work to make it work properly.
A-network
Area: Network protocol updates or fixes
A-state
Area: State / database changes
C-bug
Category: This is a bug
I-panic
Zebra panics with an internal error message
I-usability
Zebra is hard to understand or use
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.
Motivation
We want to stop Zebra panicking on shutdown.
Close #7170
Specifications
Threads:
https://doc.rust-lang.org/std/thread/struct.JoinHandle.html#method.is_finished
Async tasks:
https://docs.rs/tokio/latest/tokio/task/struct.JoinHandle.html#impl-Future-for-JoinHandle%3CT%3E
https://docs.rs/tokio/latest/tokio/task/struct.JoinError.html#method.try_into_panic
Complex Code or Requirements
This PR replaces a bunch of complex panic-handling code with consistent trait methods.
Solution
Testing
I've changed enough impls in this PR that any bugs should show up in the tests as they shut Zebra down.
Review
This is a routine bug fix.
Reviewer Checklist
Follow Up Work
We can use these methods on
JoinError
andJoinHandle
throughout Zebra, or maybe create our ownJoinHandle
andJoinError
types that automatically use these methods.