-
Notifications
You must be signed in to change notification settings - Fork 769
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
Wake the task up when inserting a new response into PendingResponses
#1735
Conversation
The CI pipeline was cancelled due to failure one of the required jobs. |
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 think in general it would be good to test all non-trivial networking changes on a live node since the test coverage of sc-network
has proven to be insufficient
@@ -79,6 +80,10 @@ impl<B: BlockT> PendingResponses<B> { | |||
); | |||
debug_assert!(false); | |||
} | |||
|
|||
if let Some(waker) = self.waker.take() { | |||
waker.wake(); |
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.
This requires that we called poll
before. Not sure that this is removing any footgun.
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.
Looking at the code we are already polling pending_responses
after we inserted any kind of element, so why is the task not waking up?
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.
This requires that we called
poll
before. Not sure that this is removing any footgun.
Yeah, but we definitely called it at least once.
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.
Looking at the code we are already polling
pending_responses
after we inserted any kind of element, so why is the task not waking up?
There is no problem with waking up right now, but it can shoot us once the polling in SyncingEngine
is converted into select!
and the order of inserting / polling pending_responses
is not strictly defined.
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.
But for a select!
. Once you insert data to the pending_responses
your match arm will be finished and you start again from the top of the loop, aka calling select!
again. This will poll all futures, including your pending_responses
futures. So, not sure why we could miss there to poll it.
This is a hot fix for #1650. Basically,
StreamMap
suffers from the same footgun asFuturesUnordered
: it must be explicitly polled in order for a newly added stream to be registered in the task. The streams are just pushed into the internal container upon insertion: https://github.com/tokio-rs/tokio/blob/master/tokio-stream/src/stream_map.rs#L445-L453This PR adds a
Waker
toPendingResponses
to make sure the task is woken up when a new response is added.