Repository navigation
fix(qmux): serialize credit updates and accept stale limits - #451
Conversation
|
Implementation complete at 54c6637. No open design decisions. The contributor chose to proceed to review and merge ( (written by claude-opus-5-5) |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Concurrent receive consumers computed a new MAX_DATA, MAX_STREAM_DATA or MAX_STREAMS limit under the credit lock but queued the frame after releasing it, so a smaller limit could overtake a larger one. The peer rejected the non-increasing value as a flow-control error and closed the session. `Credit::consume` now queues the update before unlocking. Received non-increasing limits are ignored, as RFC 9000 §19.9-§19.11 require. MAX_STREAMS above 2^60 is rejected as a FRAME_ENCODING_ERROR and MAX_STREAM_DATA on a receive-only stream is rejected, in both the Rust and TypeScript peers.
54c6637 to
1bdcc78
Compare
|
https://github.com/kixelated/quest is really cool btw |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
WalkthroughRust and TypeScript QMux credit handling now ignores non-increasing limits. Rust queues qualifying window-update frames through Priority: ➖ Normal Merge Risk: ⚪ Minimal · up to
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 54c6637f97
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
…egression Replace the bounded wait with a try_lock while the first consumer is paused inside its frame closure, so a send-after-unlock implementation fails on every run instead of only when the second thread is scheduled in time.
|
@kixelated this is ready for review. The CI workflows for this fork PR are waiting for maintainer approval ( (written by claude-opus-5-5) |
Resolve conflicts with moq-dev#437 and moq-dev#453: - rs/qmux/src/session.rs: keep main's Streams::open, which seeds a new stream's send credit and refuses registration after teardown, and adapt its increase_max call to the infallible signature. - quest/a0/README.md: drop both the Noq close cancellation entry (landed in moq-dev#453) and the QMux credit updates entry (completed here). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Merge summary (maintainer-approved
(Written by Opus 5.5) |
* quest(a0): plan QMux RFC 9000 peer-input checks Two follow-ups from #451: bound initial_max_streams transport parameters at 2^60, and refuse MAX_STREAM_DATA/STOP_SENDING for unopened locally initiated streams. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * quest(a0): pin 1002 close code and peer-stream scope in QMux checks Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Completes quest/a0/qmux-credit-updates and deletes it.
Mechanism
Credit::consumecomputed the new absolute limit under the credit mutex, but every caller queued the MAX_DATA / MAX_STREAM_DATA / MAX_STREAMS frame only after the lock was released. With concurrent consumers (for example,RecvStreamdrops on different worker threads), a smaller limit could be queued after a larger one. The receiver treated the non-increasing value asFlowControlErrorand closed the session with 1002.Changes
Credit::consume(len, control, frame)now queues the update on the unbounded control channel before it releases the lock, then wakes waiters after unlocking. This covers all four call sites:report_consumed(MAX_STREAM_DATA and MAX_DATA),Drop for RecvStream(MAX_STREAMS), and the RESET_STREAM gap and reset-first retirement paths. The closure only builds a frame, and the unbounded send never blocks, so the only new lock edge is credit → channel. No path takes a credit lock while holding the channel.increase_max/increaseMaxnow ignore a non-increasing limit without changing credit or waking waiters, as RFC 9000 §19.9–§19.11 require. TypeScript already discarded the oldfalsereturn value, so its behavior there doesn't change. Transport-parameter seeding never relied on the error.InvalidStreamId, as it already does for STOP_SENDING. Genuine receive-side flow-control violations still error, and the existing tests for them pass.Compatibility: no public API changes, and wire encodings are unchanged. Accepted peer input changes as follows: stale limits are now ignored instead of closing the session, while MAX_STREAMS > 2^60 and MAX_STREAM_DATA on a receive-only stream now close it. Main only: no 0.5 backport and no version bump.
Tests
credit::tests::concurrent_updates_are_queued_in_increasing_order: pauses the first consumer inside its frame closure, asserts the credit lock is still held, then checks that a racing second consumer queues after itconsumefails 20 out of 20 runs on the lock assertion (no timing dependence)credit::tests::non_increasing_limits_are_ignored_without_wakingincrease_maxchangesession::credit_update_tests::*: scripted peer, QMux00/01/02, uni and bidi; lower, equal and higher MAX_STREAMS / MAX_DATA / MAX_STREAM_DATA; 2^60 bound; receive-only MAX_STREAM_DATAmain(the stale-limit test fails because the session closes)wire_format_tests::max_streams_above_2_60_rejectedcredit.test.ts,frame.test.ts,session.test.tstests/credit_updates.rs: TCP loopback, multi-thread runtime, 32 tasks × 100 rounds of bidi echo plus uni sends with small windows, QMux00/01/02main(flow control erroron all three versions, plus 10 stalls; see below). 0 of 104 failed with the fix.The stalls on
mainmatched the receive hang in the second half of #439, which #437 has since fixed onmainfor any terminal teardown with a retainedSession. This PR removes the session close that triggered it in this scenario.Benchmark
cargo bench -p qmux --bench credit: bidi echo with 16 MAX_STREAMS and a 16 KiB MAX_DATA window over an in-memory duplex, QMux02, release build. The table shows streams/s, two alternating runs each:All differences are within run-to-run variance; holding the lock for the channel push costs nothing measurable.
Coordination
consumecall sites and atests/credit.rs. It will need to adopt the newconsume(len, control, frame)signature when rebased. The integration test here is namedcredit_updates.rsto avoid a file conflict.Streams::openkeeps seeding new streams' send credit, now through the infallibleincrease_max.SendStreamOptions/waitUntilAvailable: falsein TS; it usestryClaimand composes with theincreaseMaxchange here.Validation
cargo test -p qmux --all-targets --all-features, qmux doctests,bun run --cwd js/qmux test(164), andtest:interop.cargo clippy -p qmux --all-targets --all-features -D warnings,cargo hack check --feature-powerset -p qmux,cargo fmt --check,cargo sort --check,cargo shear, and the Biome /tscchecks (Biome reports the same 3 warnings as onmain).main(maintainer side):just fix(no changes),just check,just test,cargo test -p qmux --all-targets --all-features,bun run --cwd js/qmux test(166),test:interop, andquest checkall pass.Suggested follow-ups
initial_max_streams_{bidi,uni}transport parameters above 2^60 with TRANSPORT_PARAMETER_ERROR (RFC 9000 §18.2), in both Rust and TS.Closes #439
(written by claude-opus-5-5)