Repository navigation
test(e2e): split the CONTINUATION across two writes so the drain test reaches the mid-frame window - #1481
Merged
Conversation
FlorentinDUBOIS
requested review from
Wonshtrum and
llenotre
as code owners
September 23, 2026 21:35
…e protects test_h2_continuation_survives_a_graceful_drain_mid_reassembly wrote stream 3's CONTINUATION in a single TLS write, so the soft-stop drain always landed on a frame BOUNDARY: reassembly in progress, but zero.storage empty and the accumulated block already copied into ConnectionH2::header_reassembly, where no write-side site names it. graceful_goaway's GracefulDrainDecision::DeferInitial therefore protected nothing the test could observe - forcing its reassembly_in_progress argument to false left the test green, measured 3/3 at 04fade6, so the production guarantee could have been deleted outright without this test noticing (#1453). The window that decision still guards is the one h2_header_reassembly.rs names: one CONTINUATION frame mid-socket_read(), its already-read bytes parked in zero.storage while expect_read still owes the rest, which send_initial_goaway's zero.storage.clear() destroys on its way to serializing the GOAWAY. Split the CONTINUATION across two TLS writes with the drain triggered between them - the wire-level twin of the mid-frame interleave reassembly_property already generates at the unit level. No production code changed. The ordering holds by construction, not by timing; no sleep sequences the two writes. The new gate is bytes_in, which ConnectionH2::handle_read advances on every frontend socket read, PARTIAL ones included - precisely what h2.frames.rx.headers cannot do, since handle_frame ticks it only on a frame completed and it can therefore never witness a frame still arriving. read_space caps each read at exactly the bytes the current frame stage expects, so the first chunk costs exactly two reads (the 9-byte frame header, then the partial payload) and the counter settles at exactly baseline + first_chunk.len(). Reaching that total is what proves the half-read frame is parked; an overshoot fails the run loudly rather than being rounded away by the poll's <, since it would mean something other than this test's own writes feeds the counter. Discrimination re-measured, because this test's colour has been observed to track machine load rather than behaviour and one red on a quiet box settles nothing: inverting reassembly_in_progress to false now reds it 63 invocations out of 63 with no green at all - 15/15 sequentially at 1-minute load 2.2-6.4, and 48/48 under a 6-concurrent harness at load 4.5-31 - every one through the same StringDecodingError(NotEnoughOctets) HPACK decoder desync #1397/#1401 already showed, and none through any other mechanism. The unmodified guarantee is green 25/25 sequentially and 36/36 under 6-way concurrency. Under artificial 2x-CPU-oversubscription (peak 1-minute load 47.6) the changed test fails 4/48 and the UNCHANGED test measured the same way (peak 49.1) fails 11/48, both with the identical anchor_ok=true stream3_ok=false drain_witnessed=true shape: collect_response_frames's fixed 30x50ms collection window, a pre-existing property this changeset deliberately does not widen - a deadline raised to make a run land is the defect #1453 exists to remove. doc/testing.md gains the convention this defect class distils: a test for a guarantee that protects a mid-frame window has to reach that window, a whole-frame write never does, and the only thing that settles it is inverting the production decision and confirming the test turns red. Signed-off-by: Florentin Dubois <[email protected]>
FlorentinDUBOIS
force-pushed
the
fix/continuation-drain-midframe
branch
from
September 23, 2026 22:54
4aa389d to
1a59746
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.
test_h2_continuation_survives_a_graceful_drain_mid_reassemblywrote its CONTINUATION frame in a single TLS write, so it never reached the window production actually protects. Forcinggraceful_goaway'sreassembly_in_progresstofalseleft the test green 3/3 at04fade63— the guarantee could be deleted and the test would not notice.Test-only:
e2e/plus docs. Nolib/orbin/change.Why the inversion stopped reddening it
After the HEADERS+CONTINUATION reassembly extraction, the in-flight header block lives in
HeaderBlockAccumulator, notzero.storage.begin_graceful_drain'sDeferInitialdecision no longer protects that shape by itself — it protects against serializing a GOAWAY intozero.storagewhile a block accumulates there, a window the extraction closed by construction.The window it still guards is a CONTINUATION split across TCP segments mid-
socket_read. The test never got there, so the only end-to-end evidence forDeferInitialwas a test that would stay green without it.The ordering holds by construction, not by timing
The gate is
bytes_in, not a sleep.ConnectionH2::handle_readcounts every frontend socket read throughPosition::count_bytes_in_counter, partial reads included — which is precisely whath2.frames.rx.headerscannot do, sincehandle_frameticks only on a frame completed and can never witness one still arriving.read_spacecaps each read at exactly the bytes the current frame stage expects, so the first chunk (9-byte frame header plus half the payload) costs exactly two reads and the counter settles at exactlybaseline + first_chunk.len(). Reaching that total proves the half-read CONTINUATION is parked inzero.storagewithexpect_readowing the rest. An overshoot fails the run loudly rather than being rounded away by the poll's<.Backend reads land in
back_bytes_inunderPosition::Client, and the counters are cumulative — only an operator-explicitclear()resets them. Both verified in source. The two observables the prior work established were re-verified against the current tree: theserver.livegauge atlib/src/server.rs:1239-1247(written at the loop tail,shut_down_sessions()in the same iteration) and thecount!immediately before dispatch atlib/src/protocol/mux/h2.rs:4612.Discrimination, not just red-then-green
This test's colour has been measured to track load rather than behaviour — the issue records 3/3 red against correct production at load 219, and 1/3 green against inverted production at load 27. So reverting the fix and seeing red proves nothing on a quiet box. What is reported instead:
63/63 red against the inverted guarantee, zero green, every one through the identical
StringDecodingError(NotEnoughOctets)HPACK desync — #1397/#1401's signature, with no second mechanism.Each invocation is five scenario runs:
repeat_until_error_or(5, …)requires five consecutive successes, it is not a retry budget.The 4-of-48 loaded failures are not a green-under-load overclaim: all three gates passed, with shape
anchor_ok=true stream3_ok=false drain_witnessed=true, i.e.collect_response_frames's fixed 30×50 ms window. The unchanged test under identical treatment fails 11 of 48 with the same shape — pre-existing, and this change reduces it. The deadline was deliberately not widened; a timeout raised to fix a race is the defect #1453 exists to remove.A correction to the standard this was measured against
The prior work's "6-concurrent load harness" generates no load: 1.60–1.76 across 36 invocations. This test lives in 10 ms control-plane polls, so concurrency alone does not stress it. Reaching the issue's load regime took 40 CPU burners. Anyone reusing that harness as a load standard should know it is not one.
A misleading surface worth recording
The inverted red presents as a gate timeout, not an on-wire
COMPRESSION_ERROR. The desync tears the connection down, the drain finds nothing left, the worker exits,query_proxy_metricreturnsNone→0, and therx.headersgate times out. So the printed"sozu never completed stream 3's header block"is not the diagnosis — the worker's ownINVALID FRAGMENT: StringDecodingError(NotEnoughOctets)/GOT GLOBAL ERROR WHILE PROCESSING HEADERSis, and that is what was counted 63/63.Verified
446 matches the baseline exactly — the existing test was modified rather than a new one added, so the count should not move, and it did not.
One thing observed and deliberately left: the
drain_witnessedcomment still callsrepeat_until_error_or's behaviour "retries", wheredoc/testing.mdand #1410 establish it is a stability check. Pre-existing and outside this changeset.Closes #1453