Skip to content
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

Cancel node context after StopAll #8289

Merged
merged 8 commits into from Jan 25, 2021
Merged

Cancel node context after StopAll #8289

merged 8 commits into from Jan 25, 2021

Conversation

rkapka
Copy link
Contributor

@rkapka rkapka commented Jan 19, 2021

What type of PR is this?

Other

What does this PR do? Why is it needed?

#7625 removed context cancelling from the beacon node because it caused a panic - cancelling the parent context before StopAll, during which services are being shut down, caused child contexts inside these services to be cancelled before services had a chance to clean themselves up.

Last week me and @prestonvanloon discussed some related issue and it occurred to us that it's safe to cancel the parent context after all child contexts have already done their job, i.e. after StopAll. This PR adopts this solution.

Which issues(s) does this PR fix?

N/A

Other notes for review
So simple yet so clever.

@rkapka rkapka requested a review from a team as a code owner January 19, 2021 15:08
@rkapka rkapka changed the title cancel node context after StopAll Cancel node context after StopAll Jan 19, 2021
@@ -150,11 +150,11 @@ func (s *SlasherNode) Close() {
defer s.lock.Unlock()

log.Info("Stopping hash slinging slasher")
s.cancel()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same bug-prone code as in the beacon node - cancelling the parent context before StopAll is called.

@rkapka rkapka added the Ready For Review A pull request ready for code review label Jan 19, 2021
@codecov
Copy link

codecov bot commented Jan 19, 2021

Codecov Report

❗ No coverage uploaded for pull request base (develop@7f5ffb7). Click here to learn what that means.
The diff coverage is n/a.

@@            Coverage Diff             @@
##             develop    #8289   +/-   ##
==========================================
  Coverage           ?   57.12%           
==========================================
  Files              ?      449           
  Lines              ?    31524           
  Branches           ?        0           
==========================================
  Hits               ?    18007           
  Misses             ?    10719           
  Partials           ?     2798           

rauljordan
rauljordan previously approved these changes Jan 20, 2021
@rauljordan
Copy link
Contributor

Conflict and tests failing

prestonvanloon
prestonvanloon previously approved these changes Jan 21, 2021
@rkapka rkapka dismissed stale reviews from prestonvanloon and rauljordan via 3dc942b January 21, 2021 08:28
@rkapka
Copy link
Contributor Author

rkapka commented Jan 21, 2021

Conflict and tests failing

It's the duplicate wallet import test that is failing. It's causing problems in all of our PRs.

Copy link
Member

@terencechain terencechain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rkapka
Copy link
Contributor Author

rkapka commented Jan 25, 2021

How about validator?

https://github.com/prysmaticlabs/prysm/blob/master/validator/node/node.go#L151

I had not implemented this for validator because the struct did not contain ctx and cancel. I agree it's better to have consistency across all modules, so I added the relevant parts.

@rauljordan rauljordan merged commit fc8dc21 into develop Jan 25, 2021
@rauljordan rauljordan deleted the cancel-node-ctx branch January 25, 2021 15:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ready For Review A pull request ready for code review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants