-
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
p2p: seed_mode sometimes fails to send pexAddrsMessage before disconnecting gracefully #2092
Comments
@ebuchman I did a dirty fix that seem to work in pex_reactor.go: if r.config.SeedMode {
r.SendAddrs(src, r.book.GetSelectionWithBias(biasToSelectNewPeers))
go func() {
time.Sleep(5 * time.Second)
r.Switch.StopPeerGracefully(src)
}()
} I will try to submit a PR to handle shutdown gracefully properly. |
ebuchman
added a commit
that referenced
this issue
Nov 11, 2018
In seed mode, we call StopPeer immediately after Send. Since flushing msgs to the peer happens in the background, the peer connection is often closed before the messages are actually sent out. This allows all msgs to first be written and flushed out on the conn before it is closed.
ebuchman
added a commit
that referenced
this issue
Nov 11, 2018
In seed mode, we call StopPeer immediately after Send. Since flushing msgs to the peer happens in the background, the peer connection is often closed before the messages are actually sent out. This allows all msgs to first be written and flushed out on the conn before it is closed.
ebuchman
added a commit
that referenced
this issue
Nov 11, 2018
In seed mode, we call StopPeer immediately after Send. Since flushing msgs to the peer happens in the background, the peer connection is often closed before the messages are actually sent out. The new FlushStop method allows all msgs to first be written and flushed out on the conn before it is closed.
4 tasks
ebuchman
added a commit
that referenced
this issue
Nov 16, 2018
* p2p/conn: FlushStop. Use in pex. Closes #2092 In seed mode, we call StopPeer immediately after Send. Since flushing msgs to the peer happens in the background, the peer connection is often closed before the messages are actually sent out. The new FlushStop method allows all msgs to first be written and flushed out on the conn before it is closed. * fix dummy peer * typo * fixes from review * more comments * ensure pex doesn't call FlushStop more than once FlushStop is not safe to call more than once, but we call it from Receive in a go-routine so Receive doesn't block. To ensure we only call it once, we use the lastReceivedRequests map - if an entry already exists, then FlushStop should already have been called and we can return.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When
SeedMode
is true, the PexReactor sends a batch of addresses and calls StopPeerGracefully. It seems sometimes the peer ends up disconnecting before these messages are delivered, which makes it difficult for a new node to join the network.It looks like we don't call .flush() in the MConnection.OnStop(). I tried adding that on the seed node, but even still the new node sometimes fails to receive any addresses from the seed.
The text was updated successfully, but these errors were encountered: