-
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: cleanup persistent connection retries #982
Conversation
…fallback to default port In this commit, we fix an existing bug within the codebase: if a peer connected to us inbound, then we'd attempt to use the assigned port when re-establishing a connection to them. We fix this issue in this commit by adding a new method to look up any advertisements for the peer, and use the specified port that matches our connection attempt. If we can't find a proper advertisement, then we'll simply use the default peer port.
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.
These changes look good to me.
In this commit, we fix a minor bug in the prior versions of lnd. Before this commit, if we received a new inbound connection for channel creation, the channel was created, and then the peer disconnected, we wouldn't automatically reconnect. In this commit we fix this issue by overloading the WatchNewChannel method to also accept the peer's ID so we can add it to the set of persistent connections.
bc13190
to
ffa2a9e
Compare
lnd.go
Outdated
addr *lnwire.NetAddress) error { | ||
|
||
// First, we'll mark this new peer as a persistent | ||
// re-connection purposes. |
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.
(nit) comment typo "... as a persistent [peer for] re-connection purposes."
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.
Fixed, thanks!
dba8c5a
to
d0a4231
Compare
This commits changes the behavior of our connection reestablishment, and resolves some minor issues that could lead to uncancelled requests or an infinite connection loop. - Will not attempt to Remove connection requests with an ID of 0. This can happen for reconnect attempts that get scheduled, but have not started at the time the server cancels the connection requests. - Adds a per-peer cancellation channel, that is closed upon a successful inbound or outbound connection. The goroutine spwaned to handle the reconnect by the peerTerminationWatch now selects on this channel, and skips reconnecting if it is closed before the backoff matures. - Properly computes the backoff when no entry in persistentPeersBackoff is found. Previously, a value of 0 would be returned, cause all subsequent backoff attempts to use a backoff of 0. - Cancels a peers retries and remove connections immediately after receiving an inbound connection, to mimic the structure of OutboundPeerConnected. - Cancels all persistent connection requests after calling DisconnectPeers. - Allow additional connection attempts to peers, even if there already exists a pending connection attempt.
Alters the behavior of ConnectEnsure to initiate a connection attempt in both directions. Additionally, the wait predicate only returns true after cross checking both peer lists.
6a5f46b
to
c8323a4
Compare
Uses EnsureConnected when reconnecting nodes in: - switch offline delivery persistence - graph topology notifications - channel funding persistence
c8323a4
to
7db7c9c
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 🎉
Complementary to #981.
This commits changes the behavior of our connection
reestablishment, and resolves some minor issues that
could lead to uncancelled requests or an infinite
connection loop.
Will not attempt to Remove connection requests with
an ID of 0. This can happen for reconnect attempts
that get scheduled, but have not started at the
time the server cancels the connection requests.
Adds a per-peer cancellation channel, that is
closed upon a successful inbound or outbound
connection. The goroutine spwaned to handle the
reconnect by the peerTerminationWatch now
selects on this channel, and skips reconnecting
if it is closed before the backoff matures.
Properly computes the backoff when no entry in
persistentPeersBackoff is found. Previously, a
value of 0 would be returned, cause all subsequent
backoff attempts to use a backoff of 0.
Cancels a peer's retries and remove connections
immediately after receiving an inbound connection,
to mimic the structure of OutboundPeerConnected.
Fixes #935, #941, #979, #982.