Skip to content

fix(mux-h2): rotate the RFC 9218 incremental tail in every urgency bucket, not just the leading one - #1492

Merged
FlorentinDUBOIS merged 1 commit into
mainfrom
fix/h2-per-bucket-rotation
Sep 24, 2026
Merged

FlorentinDUBOIS merged 1 commit into
mainfrom
fix/h2-per-bucket-rotation

Conversation

@FlorentinDUBOIS

Copy link
Copy Markdown
Collaborator

Closes #1456.

Prioriser held one connection-global incremental_cursor, so only the lowest-numbered urgency bucket with a ready incremental stream could ever commit a leader. A cursor sitting entirely below — or above — another bucket's id range makes partition_point return a constant, and rotate_left(0) is a no-op forever.

The issue's measured case, u=0 incremental {1,3} + u=3 incremental {5,7}, all ready, all consuming, six passes:

before  [[1,3,5,7], [3,1,5,7], [1,3,5,7], [3,1,5,7], [1,3,5,7], [3,1,5,7]]
after   [[1,3,5,7], [3,1,7,5], [1,3,5,7], [3,1,7,5], [1,3,5,7], [3,1,7,5]]

The u=0 tail alternated correctly all along. The u=3 tail was 5,7 in every pass — stream 7 never led its bucket.

Today that is positional starvation: every stream still gets its frame. It becomes byte starvation the moment a pass is cut short — a stalled flush partway through the order leaves the trailing streams unwritten, pass after pass, always the same ones, because the order never rotates. RFC 9218 §4 specifies round-robin within an urgency level without qualification, so the old behaviour was a partial implementation rather than a deliberate policy.

Wire-ordering evidence, which the issue asked for over unit tests

New test_h2_per_bucket_incremental_rotation: four streams, u=0,i on 1/3 beside u=3,i on 5/7, 96 KiB bodies, four backends, using the INITIAL_WINDOW_SIZE=0 + bulk-WINDOW_UPDATE handshake so one fully-populated four-stream pass is released. It splits the DATA trace into passes on the leading bucket and reads each bucket's first-of-pair.

before   u=0 leader per pass: [1, 1, 3, 1, 3, 1]     u=3 leader per pass: [5, 5, 5, 5, 5, 5, 5]
after    u=0 leader per pass: [1, 1, 3, 1, 3, 1]     u=3 leader per pass: [5, 7, 5, 7, 5, 7, 5]
         leading_rotates=true  trailing_rotates=false  →  both true

Stream 7 leads zero of seven passes before, three of seven after, on a real TLS wire. repeat_until_error_or(3, …): 3/3 consecutive.

The sharpest check in the changeset: restoring the faithful pre-fix behaviour — the lowest urgency's leader written to every cursor — reds exactly 3 of 1093 sozu-lib tests, all three the new coverage, with the other 1090 green. That measures that the leading bucket's semantics are unchanged, which is the second prohibition in the issue.

What changed

  • incremental_cursor: [StreamId; 8] replacing the single id. Urgency is [0, 7] and already clamped, so the array is exact — no bounds fallback that would imply otherwise.
  • first_incremental_fired: [Option<StreamId>; 8] and advance_incremental_cursor(&[Option<StreamId>; 8]).
  • note_fired(&mut self, urgency: u8, stream_id: StreamId, is_incremental: bool, consumed: i32) — urgency first, matching the existing note_ineligible(urgency, is_incremental). The census could not previously attribute a firing stream to a bucket; the issue named this signature change as the non-obvious part of the work.
  • end_pass commits each bucket's own leader instead of one connection-global id.

The pinning test was deleted, not edited

the_round_robin_cursor_is_connection_global_so_only_the_leading_bucket_rotates is deleted (83 lines); its expectation was never touched. Its doc comment said explicitly that editing it in place would convert a deliberate record into a silent rewrite. The scenario moved to every_urgency_bucket_rotates_its_own_incremental_tail with a corrected oracle, and fairness_property's generator gained a second multi-peer incremental bucket at strictly lower priority — its oracle moved from "the main bucket's leader" to the cyclic successor of every generated bucket, built from a grouping of the plan's own entries so a distractor colliding into a bucket is covered.

Blast radius the issue did not name: the citation gate fails on a backticked test name that resolves to no fn, and two historical [Unreleased]/Changed entries describe the extraction commits by that name. Rewriting them would misstate what those commits did. Used the checker's documented RENAMED_TESTS forwarding — the same shape as its existing sozu#1350/#1356 entries — which keeps the pointer live and requires the target itself to resolve. Not NOT_A_TEST, which would be silencing.

Not BREAKING

mod h2_scheduler; is private in mux/mod.rs, so Prioriser and its pub fn advance_incremental_cursor are unreachable outside sozu-lib — no published signature moves. No proto, config key, CLI flag or metric name changes. HTTP/2 offers no cross-stream ordering guarantee and RFC 9218 §4 is unqualified, so the new order is more conformant rather than a different contract. Filed under ### 🐛 Fixed, with the observable change named: on a connection with two populated incremental buckets, the trailing bucket's DATA order was stable and now rotates.

Downstream stability sweep, dispositioned: try_h2_mixed_urgency_incremental_solo_drains and try_h2_customer_har_shape_drains hold exactly one incremental stream per bucket; try_h2_rfc9218_incremental_round_robin and try_h2_mid_pass_rst_does_not_force_yield are single-bucket. One peer leaves nothing to rotate and a lone bucket was always the leader — unaffected by construction, and all pass.

Reference sweep

note_fired, incremental_cursor, advance_incremental_cursor, end_pass, first_incremental_fired and the deleted test name, repo-wide, no file-type filter.

updated — h2_scheduler.rs (all sites), h2.rs call site and its four-mechanism note, h2_transmit.rs (its fairness section asserted the frozen trailing bucket as current behaviour — now past tense), h2_write_pass.rs ×2, LIFECYCLE.md invariant 26 (rewritten to per-bucket scope), doc/h2_mux_internals.md ×8, doc/testing.md, and lib/benches/h2_scheduling.rs, which carries its own incremental_cursor/partition_point copy.

unaffected — six historical CHANGELOG.md entries (rewriting them would misstate those commits; the dead name is forwarded); h2_flow_control.rs's citation of the cursor as a design precedent, still true per-bucket; h2_write_pass.rs's references to the begin_pass/end_pass pairing, whose signature did not change; h2.rs's generic "once per" ordering claim, still accurate.

Verification

cargo +nightly fmt --all -- --check                                   exit 0
cargo build  --locked --no-default-features --features crypto-ring,…  exit 0
cargo clippy --all-targets --locked … -- -D warnings                  exit 0
cargo test -p sozu-lib --locked …    ok. 1101 passed; 0 failed        (1100 + 1 net)
cargo test -p sozu     --locked …    ok. 113 passed; 0 failed
cargo test -p sozu-e2e --locked … -- --skip tests::fuzz_tests::
                                     ok. 447 passed; 0 failed
check_doc_citations.py --root .      211 citations, 533 test names, 16 pinned blocks
check_doc_citations.py --base 9472cd96   327 compared, 0 exempt spans
check_doc_citations.py --self-test   exit 0; broken fixture tree exits 1 as ci.yml asserts
RUSTDOCFLAGS="-D warnings" cargo doc --no-deps --all-features --locked   exit 0

No test newly ignored, no assertion loosened, no lint escape, no #[allow] added. The one deletion is the pinning test, which the issue mandates.

`Prioriser` held ONE connection-global `incremental_cursor`.
`apply_incremental_rotation` applied it to every urgency bucket's
incremental tail, but `H2Scheduler::end_pass` could only ever commit an
id drawn from the lowest-numbered urgency bucket that had a ready
incremental stream fire — the pass order is ascending by urgency, so the
first stream to consume send window always came from there. Every other
bucket was rotated by a cursor from a foreign id range, and a cursor
sitting entirely below or entirely above a bucket's own ids makes
`partition_point` return a constant, so `rotate_left(0)` was a no-op
forever.

Measured, u=0 incremental {1, 3} beside u=3 incremental {5, 7}, all
ready and all consuming, six passes:

  [[1,3,5,7], [3,1,5,7], [1,3,5,7], [3,1,5,7], [1,3,5,7], [3,1,5,7]]

The u=0 tail alternates as invariant 26 promised; the u=3 tail is 5, 7
in every pass and stream 7 never leads its bucket. It now reads

  [[1,3,5,7], [3,1,7,5], [1,3,5,7], [3,1,7,5], [1,3,5,7], [3,1,7,5]]

Positional starvation today — every stream still gets its frame, just
never the lead position in its bucket — and byte starvation the moment a
pass is cut short, since a stalled flush leaves the same trailing
streams unwritten pass after pass.

Three changes carry it. `incremental_cursor: [StreamId; 8]`, exact
rather than a cap because RFC 9218 §4.1 urgency is [0, 7] and
`Prioriser::push_priority` already clamps into it. A per-bucket
`first_incremental_fired` in `ReadyIncrementalCensus`, with `end_pass`
committing each bucket's own leader. And
`ReadyIncrementalCensus::note_fired` now takes the urgency, matching
`note_ineligible`'s existing shape — without it the census cannot
attribute the firing stream to a bucket and can only name one leader per
connection. The leading bucket's semantics are unchanged: each bucket
still commits the FIRST stream of that bucket which consumed window,
never the last, and `consumed > 0` stays load-bearing.

This changes bytes on the wire, so it carries e2e evidence rather than
an argument. `test_h2_per_bucket_incremental_rotation` reads the
trailing bucket's leader out of the DATA frame trace: before,
`[5, 5, 5, 5, 5, 5, 5]` over seven passes; after, `[5, 7, 5, 7, 5, 7, 5]`.
Not marked breaking — `mod h2_scheduler` is private so no published API
signature moves, no configuration key, CLI flag, protobuf message or
metric name changes, and HTTP/2 offers no cross-stream ordering
guarantee a peer could have depended on. The new order is more
conformant to RFC 9218 §4, not a different contract.

`the_round_robin_cursor_is_connection_global_so_only_the_leading_bucket_rotates`
is deleted rather than re-expected, as its own doc comment asked. Its
scenario is now `every_urgency_bucket_rotates_its_own_incremental_tail`,
and `fairness_property` gained a second multi-peer incremental bucket at
strictly lower priority with a per-bucket oracle. Restoring the global
commit reds exactly three of sozu-lib's 1093 tests, all three of them
this changeset's new coverage, and leaves the other 1090 green.

Refs #1456

Signed-off-by: Florentin Dubois <[email protected]>
@FlorentinDUBOIS
FlorentinDUBOIS force-pushed the fix/h2-per-bucket-rotation branch from ab1ae41 to 2bcfc9f Compare September 24, 2026 05:14
@FlorentinDUBOIS
FlorentinDUBOIS merged commit ea228bc into main Sep 24, 2026
28 checks passed
@FlorentinDUBOIS
FlorentinDUBOIS deleted the fix/h2-per-bucket-rotation branch September 24, 2026 05:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The RFC 9218 incremental cursor is connection-global, so only the leading urgency bucket ever rotates

1 participant