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

Fix next_retry busy waiting on first retry #4192

Merged
merged 4 commits into from
Apr 18, 2024

Conversation

alexggh
Copy link
Contributor

@alexggh alexggh commented Apr 18, 2024

The next_retry_time gets populated when a request receives an error timeout or any other error, after thatn next_retry would check all requests in the queue returns the smallest one, which then gets used to move the main loop by creating a Delay

futures_timer::Delay::new(instant.saturating_duration_since(Instant::now())).await,

However when we retry a task for the first time we still keep it in the queue an mark it as in flight so its next_retry_time would be the oldest and it would be small than now, so the Delay will always triggers, so that would make the main loop essentially busy wait untill we received a response for the retry request.

Fix this by excluding the tasks that are already in-flight.

The `next_retry_time` gets populated when a request receives an error
timeout or any other error, after thatn next_retry would check all
requests in the queue returns the smallest one, which then gets used to
move the main loop by creating a Delay
```
futures_timer::Delay::new(instant.saturating_duration_since(Instant::now())).await,
```

However when we retry a task for the first time we still keep in the
queue an mark it as in flight so its next_retry_time would be the oldest
and it would be small than `now`, so the Delay will always triggers, so
that would make the main loop essentially busy wait untill we received a
response for the retry request.

Fix this by excluding the tasks that are already in-flight.

Signed-off-by: Alexandru Gheorghe <alexandru.gheorghe@parity.io>
@alexggh alexggh added the R0-silent Changes should not be mentioned in any release notes label Apr 18, 2024
alexggh and others added 2 commits April 18, 2024 15:37
Co-authored-by: Andrei Sandu <54316454+sandreim@users.noreply.github.com>
Signed-off-by: Alexandru Gheorghe <alexandru.gheorghe@parity.io>
@alexggh alexggh enabled auto-merge April 18, 2024 12:41
@alexggh alexggh added the T0-node This PR/Issue is related to the topic “node”. label Apr 18, 2024
@alexggh alexggh added this pull request to the merge queue Apr 18, 2024
Merged via the queue into master with commit 0e55289 Apr 18, 2024
129 of 137 checks passed
@alexggh alexggh deleted the alexaggh/fix_busy_waiting_statement_distribution branch April 18, 2024 16:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
R0-silent Changes should not be mentioned in any release notes T0-node This PR/Issue is related to the topic “node”.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants