-
Notifications
You must be signed in to change notification settings - Fork 248
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 connected peers bombarding peers with connection attempts #2208
Conversation
It'd be great if you could write test for this edge case as well, @shamil-gadelshin |
a938ca1
to
73874a0
Compare
Removed one unnecessary waker call |
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.
Did you test these changes for real connection persistence between our apps?
@@ -508,7 +529,9 @@ impl<Instance: 'static + Send> NetworkBehaviour for Behaviour<Instance> { | |||
|
|||
for (peer_id, address) in peer_addresses { | |||
self.known_peers.entry(peer_id).or_insert_with(|| { | |||
ConnectionState::Connecting { | |||
cx.waker().wake_by_ref(); |
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.
I wonder, will it work while we process the current poll()?
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.
I would be VERY surprised if it didn't. This is how futures work and how this should work as well.
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.
Did you test these changes for real connection persistence between our apps?
This changes nothing about persistence, only how we establish connections. And as we were debugging earlier I wasn't really connect to anyone to check persistence.
@@ -508,7 +529,9 @@ impl<Instance: 'static + Send> NetworkBehaviour for Behaviour<Instance> { | |||
|
|||
for (peer_id, address) in peer_addresses { | |||
self.known_peers.entry(peer_id).or_insert_with(|| { | |||
ConnectionState::Connecting { | |||
cx.waker().wake_by_ref(); |
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.
I would be VERY surprised if it didn't. This is how futures work and how this should work as well.
Since we don't have either manual testing or unit testing I would postpone the PR until we perform some form of testing. Otherwise, we introduce un untested major change to the protocol. |
73874a0
to
41c9880
Compare
The first commit is just some logging tweaks, some formatting and some to debug what is going on better.
The second commit fixes following thing I observed in logs (note the time difference between lines):
Essentially the way
fn poll
was written the following happened:ConnectionState::Connecting
(but waker wasn't called, so there was no guarantee it will ever actually dial that peer)ConnectionState::Connecting
This change both fixes missing waker call and introduces
ConnectionState::ToConnect
that is used to indicate that connection should be initiated, but it didn't actually happen yet.This doesn't fix networking issues I observe fully, but this seems like a clear bug that should be fixed anyway.
Code contributor checklist: