-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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 logic issue: handlers.removePeer() is called twice. #856
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
[R4R] Release v1.1.8
[R4R] Release v1.1.9
There is a logic issue which cause "Ethereum peer removal failed, err=peer not registered" occur quite often. handler.runEthPeer set up a defer removePeer(). This is always called after a peer is disconnected. However removePeer is also called by mulitple functions like downloader/fetcher. After those kind of functions removePeer(), peer handler executes defer removePeer(). This makes removePeer() happened twice, and this is the reason we often see "Ethereum peer removal failed, err=peer not registered". To solve this, removePeer only needs to hard Disconnect peer from networking layer. Then defer unregisterPeer() will do the cleanup task after then.
reference from go-thereum.
Thanks for the contribution. We will start review ASAP. |
unclezoro
approved these changes
Apr 20, 2022
LGTM |
This was referenced Apr 20, 2022
j75689
approved these changes
Apr 20, 2022
pythonberg1997
approved these changes
Apr 20, 2022
keefel
approved these changes
Apr 20, 2022
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
This was referenced May 2, 2022
baptiste-b-pegasys
added a commit
to baptiste-b-pegasys/quorum
that referenced
this pull request
May 27, 2022
achraf17
pushed a commit
to Consensys/quorum
that referenced
this pull request
May 30, 2022
j75689
pushed a commit
to j75689/bsc
that referenced
this pull request
Jun 15, 2022
* fix logic issue: handlers.removePeer() is called twice. There is a logic issue which cause "Ethereum peer removal failed, err=peer not registered" occur quite often. handler.runEthPeer set up a defer removePeer(). This is always called after a peer is disconnected. However removePeer is also called by mulitple functions like downloader/fetcher. After those kind of functions removePeer(), peer handler executes defer removePeer(). This makes removePeer() happened twice, and this is the reason we often see "Ethereum peer removal failed, err=peer not registered". To solve this, removePeer only needs to hard Disconnect peer from networking layer. Then defer unregisterPeer() will do the cleanup task after then. * fix: modify test function for close testing. reference from go-thereum. Co-authored-by: zjubfd <[email protected]>
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.
Description
There is a logic issue which causes "Ethereum peer removal failed, err=peer not registered" occur quite often.
Related issues #220 #670 #821
Rationale
handler.runEthPeer()
set up adefer removePeer().
This is always called after a peer is disconnected.However removePeer is also called by multiple functions like downloader/fetcher. After those kind of functions call
removePeer()
, peer handler executesdefer removePeer()
. This makesremovePeer()
happened twice, and this is the reason we often see "Ethereum peer removal failed, err=peer not registered".Just took a look, go-ethereum code here is exactly using this new logic
Changes
Notable changes:
removePeer()
hard Disconnect peer from networking layer.defer unregisterPeer()
will called byhandler.runEthPeer()
, do the cleanup task after then.NewPeerPipe()
underp2p.Peer
, for RW close testing. The code is referenced from go-ethereum-p2p-peer