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

Don't reconnect to dead peers at startup #2005

Open
pm47 opened this issue Oct 11, 2021 · 0 comments
Open

Don't reconnect to dead peers at startup #2005

pm47 opened this issue Oct 11, 2021 · 0 comments

Comments

@pm47
Copy link
Member

pm47 commented Oct 11, 2021

Currently, at startup we attempt to reconnect to all peers with which we have a channel, even if we were disconnected for a long time when eclair was stopped.

if (nodeParams.autoReconnect && nextPeerData.channels.nonEmpty) { // we only reconnect if nodeParams explicitly instructs us to or there are existing channels

Note that we only try once, and then we immediately set a large delay before attempting a reconnection:

// When restarting, we will ~immediately reconnect, but then:
// - we don't want all the subsequent reconnection attempts to be synchronized (herd effect)
// - we don't want to go through the exponential backoff delay, because we were offline, not them, so there is no
// reason to eagerly retry
// That's why we set the next reconnection delay to a random value between MAX_RECONNECT_INTERVAL/2 and MAX_RECONNECT_INTERVAL.
val firstNextReconnectionDelay = nodeParams.maxReconnectInterval.minus(Random.nextInt(nodeParams.maxReconnectInterval.toSeconds.toInt / 2).seconds)

But we could be even more aggressive and not attempt at all to reconnect: we could instead simply pick up the exponential backoff delay for reconnection where we left it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant