Skip to content

test(e2e): split the CONTINUATION across two writes so the drain test reaches the mid-frame window - #1481

Merged
FlorentinDUBOIS merged 1 commit into
mainfrom
fix/continuation-drain-midframe
Sep 23, 2026
Merged

FlorentinDUBOIS merged 1 commit into
mainfrom
fix/continuation-drain-midframe

Conversation

@FlorentinDUBOIS

Copy link
Copy Markdown
Collaborator

test_h2_continuation_survives_a_graceful_drain_mid_reassembly wrote its CONTINUATION frame in a single TLS write, so it never reached the window production actually protects. Forcing graceful_goaway's reassembly_in_progress to false left the test green 3/3 at 04fade63 — the guarantee could be deleted and the test would not notice.

Test-only: e2e/ plus docs. No lib/ or bin/ change.

Why the inversion stopped reddening it

After the HEADERS+CONTINUATION reassembly extraction, the in-flight header block lives in HeaderBlockAccumulator, not zero.storage. begin_graceful_drain's DeferInitial decision no longer protects that shape by itself — it protects against serializing a GOAWAY into zero.storage while 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 for DeferInitial was 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_read counts every frontend socket read through Position::count_bytes_in_counter, partial reads included — which is precisely what h2.frames.rx.headers cannot do, since handle_frame ticks only on a frame completed and can never witness one still arriving.

read_space caps 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 exactly baseline + first_chunk.len(). Reaching that total proves the half-read CONTINUATION is parked in zero.storage with expect_read owing the rest. An overshoot fails the run loudly rather than being rounded away by the poll's <.

Backend reads land in back_bytes_in under Position::Client, and the counters are cumulative — only an operator-explicit clear() resets them. Both verified in source. The two observables the prior work established were re-verified against the current tree: the server.live gauge at lib/src/server.rs:1239-1247 (written at the loop tail, shut_down_sessions() in the same iteration) and the count! immediately before dispatch at lib/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:

production harness 1-min load result
correct 25× sequential 1.85–2.39 25/25 pass
correct 6-concurrent × 6 1.60–1.76 36/36 pass
correct 6-conc × 8 + 40 CPU burners 17.1–47.6 44/48 pass
inverted 15× sequential 2.2–6.4 0/15 pass
inverted 6-conc × 8 + 40 burners 4.6–31.1 0/48 pass
baseline (unchanged test), correct 6-conc × 8 + 40 burners 20.4–49.1 37/48 pass

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_metric returns None → 0, and the rx.headers gate times out. So the printed "sozu never completed stream 3's header block" is not the diagnosis — the worker's own INVALID FRAGMENT: StringDecodingError(NotEnoughOctets) / GOT GLOBAL ERROR WHILE PROCESSING HEADERS is, and that is what was counted 63/63.

Verified

cargo +nightly fmt --all -- --check                          -> exit 0
cargo clippy --all-targets --locked --no-default-features \
  --features crypto-ring,opentelemetry,splice,simd -- -D warnings  -> exit 0, 0 warnings
cargo test -p sozu-e2e ... -- --skip tests::fuzz_tests::     -> 446 passed; 0 failed; 4 filtered out
check_doc_citations.py --root . --base 04fade63              -> exit 0

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_witnessed comment still calls repeat_until_error_or's behaviour "retries", where doc/testing.md and #1410 establish it is a stability check. Pre-existing and outside this changeset.

Closes #1453

…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
FlorentinDUBOIS force-pushed the fix/continuation-drain-midframe branch from 4aa389d to 1a59746 Compare September 23, 2026 22:54
@FlorentinDUBOIS
FlorentinDUBOIS merged commit c10b94a into main Sep 23, 2026
24 checks passed
@FlorentinDUBOIS
FlorentinDUBOIS deleted the fix/continuation-drain-midframe branch September 23, 2026 23:45
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 CONTINUATION+drain e2e test never reaches the mid-frame window its production guarantee protects

1 participant