Repository navigation
fix(quic): rerun stuck-window eviction after plain reads and handle window shrinks - #9711
Merged
Merged
Conversation
Quest-Claim: 20feeefc08287986
…nd shrinks A restore reran the stuck pass only when a pass had found that lease out, so a pass held off by a ready or unleased stream never reran once its reader looked and parked elsewhere. A restore now reruns it while any reader waits (StreamsState::waiting). A plain read whose credit only pays a shrunk window's debt reruns it too. Shrinking the window wakes leases waiting for more than it now holds, and reports a MAX_DATA the smaller batch makes due. ReceiveCredit.tla models plain-read streams, shrink debt, and readers parking on another reader after a restore; ReceiveCreditMixed.cfg fails with either fix reverted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Rerunning stuck-window eviction in restore() whenever another reader waits evicts active moq-net readers mid-decode (between poll_has_more/peek and decode, or mid-segment in poll_read_frame) while another stream waits on a full window. Restore the stuck_waiting gate so restore() reruns eviction only when a pass waited on that lease while it was out, document the parking contract on restore(), replace the waiter-rule test with restore_mid_decode_does_not_evict_active_reader, and drop Idle from ReceiveCredit.tla while keeping plain-read and shrink-debt coverage.
kixelated
marked this pull request as ready for review
November 27, 2026 02:23
Contributor
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 1 minute. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
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.
Finishes quest/m1/quic-eviction-deadlock.md.
Problem
A full receive window could deadlock with every reader parked, because nothing reran the stuck-window pass or woke over-window readers:
read()whose returned credit only paidreceive_window_shrink_debtnever reran the pass that its unread data had held off.receive_windowleft a lease waiting for more than the new window parked forever, and never reported aMAX_DATAthat the smaller batch made due.Approach
Chunks::finalize_inner()rerunsevict_if_stuck()after returning credit. When the window has room this returns in O(1).set_receive_window()on a shrink wakes readers whosewantexceeds the new window (wake_too_large), so their next lease fails withTooLarge, and returnsmax_data_due(). It runs no pass: a shrink changes neitherwindow_max_datanordata_recvd, so whether the window is stuck stays the same.Stream::restore()keeps thestuck_waitinggate (rerunning eviction only when an earlier pass waited on that lease while it was out) and documents that a reader parking elsewhere while holding leased bytes must release or stop its stream.ReceiveCredit.tlanow models plain-read streams (Plain) and shrink debt (Shrink). The newReceiveCreditMixed.cfgcovers them, andReceiveCreditMixedGuards.cfgchecksGuardedon the new steps.Choices made without asking
.claude/skills/verify-credit/SKILL.mdwas not moved, sincers/moq-net/src/lite/publisher.rshas substantial unrelated changes since7cab21e65bthat this PR does not re-audit.Impact
TooLarge) after a shrink, where before the connection hung.Validation
rs/moq-quic/src/connection/streams/state.rs:read_into_shrink_debt_evicts,shrink_below_a_want_wakes_it,shrink_sends_batched_credit, andrestore_mid_decode_does_not_evict_active_reader.just check origin/main: 12,447 Rust tests passed (165 skipped), plus clippy, rustdoc, fmt, biome, markdown, quest, shell, toml, nix, justfile, and coverage_tables checks.sh/tla.shover all 7ReceiveCredit*.cfgconfigs: all passed (ReceiveCreditMixed: 633k states in 11s;ReceiveCreditMixedGuards: 1.1k states in 2s;ReceiveCreditGuards: 10.3k states in 8 min).SendCredit.tlais unchanged.quest check --base origin/main --branch quest/m1/quic-eviction-deadlock: passed (559 documents checked).Caused by
Chunks::finalize_inner) and noTooLargewakeup ormax_data_duecheck to window shrinks (set_receive_window) (found by reviewer; themoq-quicaudit, quest: plan moq-quic audit fixes, ACK packing, sendmmsg, and coverage #9707).Decisions
recv::Stream::restore()behave? ✅ Restore the oldstuck_waitinggate (rejected: AddStream::park(lease)and amoq-tokiowrapper; Keep the waiter rule and count parked plain readers too). Inmoq-net, dropping aLeasecallsrestore()betweenpoll_has_more/peek and decode, on short reads, and mid-segment inpoll_read_frame; rerunning eviction whenever another reader waits evicts active readers mid-decode (round 1 finding 1), and counting parked plain readers would not fix that. No current consumer parks on another connection stream after a restore, sorestore()keepsstuck_waitingand documents that a reader parking elsewhere with leased bytes must release or stop them.Follow-ups
None.
Models
Size: S
Implementer: Claude Code, claude-opus-5-5, unknown (arm A)
Implementer: Antigravity, gemini-4-neon, high effort
(Written by Gemini 4 Neon with high effort)
Review
Rewritten by
quest reviewafter each round.Head: 6933ee0
Base: origin/main at 54c862e
Risk: medium,
A wrong eviction or credit change in moq-quic's receive path (lease.rs, recv.rs, state.rs) could stall or evict streams for relay and client users once a release cut ships it, and it is easy to undo by reverting the commits, since the public API and wire format are unchanged and the verify and quest files are docs or models.Classified: medium by Claude Code, claude-haiku-5-5, low effort, session
c794b7c9-9d40-46d1-8c8e-00027b9fa76fRisk file: bb7b1c0de60b
Reviewer: Codex, gpt-6.2-sol, medium effort
Session:
01a21a8b-66d1-7633-87ac-0ad81508cf0b, round 3Score: 10/10,
The head is ready to land because the peek race already exists at the merge base and no findings remain in the branch’s changes.Rounds: 3; first round 2 (high 1, medium 1); findings 2 (medium 2): fixed 1, refuted 1, open 0
Findings: none
The last round's findings, at 6933ee0:
rs/moq-quic/src/connection/streams/lease.rs:420:Keep a peeked header readable when an arrival fills the window;The merge-base patch for `rs/moq-quic/src/connection/streams/lease.rs:420` shows that the branch changes only the `restore()` documentation and comments, leaving both the eviction guard and the logic that arms it unchanged.