-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
server: stagger connReqs to multi-address peers #5925
server: stagger connReqs to multi-address peers #5925
Conversation
b78dd4c
to
a73f599
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.
Thanks for the quick fix! Only major comments are re improper typing of the constant controlling delay (appears to be using nanoseconds rn) and also the interplay between this and the existing stagger connection config/flag
Delete all the stored addresses from the persistentPeerAddr map when we prune the persistent peer.
Let the connectToPersistentPeer func handle all connection attempts to persistent peers so that that logic is in once place.
Thanks for the review @Roasbeef 🚀 see my comment above re this stagger vs the existing stagger connection config/flag (tldr: existing stagger is for connection between multiple different peers and this stagger is for trying multiple addresses for the same peer so slightly different behaviour is wanted imo) |
In this commit, we stagger the connection attempts to the multiple addresses of a peer.
a73f599
to
ac4fe5f
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.
LGTM 🍂
Have one small thing will fix in a follow up commit.
Currently if a peer has multiple working addresses (like 1 clearnet & 1 tor) we will, on startup and during reconnection, attempt to connect to all their advertised addresses at once. The peer will then accept the first connection and so we will cancel the second one but it already reaches the peer and so then they close the first connection in favour of the second one.
I have tested that this would also happen pre #5538 when
establishPersistentConnections
would kickoff all the connReqs at once but it would then recover sincepeerTerminationWatcher
would only try to connect to a single address. With #5538,peerTerminationWatcher
also uses all the advertised addresses during it's reconnection attempt and so the issue just keeps repeating itself.In this PR: if we have multiple addresses stored for a peer, we stagger the creation of the connReqs for those addrs.
Fixes #5887