fix(conn): handle overdue timers under Tokio budget exhaustion#2677
Open
syszery wants to merge 2 commits into
Open
fix(conn): handle overdue timers under Tokio budget exhaustion#2677syszery wants to merge 2 commits into
syszery wants to merge 2 commits into
Conversation
Member
|
(Not sure why this is draft? Will hold off on reviewing for now.) |
Contributor
Author
|
Thanks. I just double checked something. The PR is ready for review now. |
Ralith
approved these changes
Jun 12, 2026
Member
|
I'd like to have this split in two commits:
A bunch of comments were removed -- were those removals motivated or just LLM collateral? |
Contributor
Author
|
The PR is split into two commits now. The comment changes were intentional:
|
drive_timer() used AsyncTimer::poll() to determine whether a protocol deadline had elapsed. Under Tokio's cooperative task budget, Sleep::poll() may return Poll::Pending for an already-expired deadline once the task's budget is exhausted, which can happen when process_conn_events() drains a busy channel. As a result, handle_timeout() is not called even though the deadline has already elapsed. For QUIC, timers such as PTO, loss detection, and idle timeouts are correctness-critical and should not be deferred to a later scheduling round. Fix this by checking runtime.now() >= deadline before consulting the async timer. The clock is not subject to cooperative budgeting. The timer remains responsible only for registering a wakeup when the deadline lies in the future.
1821a05 to
881664d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This fixes a correctness issue where QUIC protocol timers could fail to fire within a scheduling round under load when Tokio’s cooperative task budget is exhausted.
drive_timer()previously relied onAsyncTimer::poll()to determine whether a deadline had elapsed. However,Sleep::poll()may returnPoll::Pendingfor already-expired deadlines once the task has exhausted its cooperative budget. In that case,handle_timeout()would not be called until a later scheduling round, despite the deadline having already passed.This addresses the timer starvation aspect of #753.
Fix
The timer logic is changed to:
runtime.now() >= deadlinebefore polling the async timer