Skip to content

proxy: carried patch — a draining hot-restart parent answers its own time-wait QUIC connections instead of forwarding them to the child (#1054) - #1066

Merged
bpalermo merged 1 commit into
mainfrom
proxy/1054-quic-time-wait-before-forward
Sep 29, 2026
Merged

bpalermo merged 1 commit into
mainfrom
proxy/1054-quic-time-wait-before-forward

Conversation

@bpalermo

Copy link
Copy Markdown
Owner

Carries proxy/bazel/patches/envoy-aether1054b-quic-time-wait-before-forward.patch on the 726d7ac pin, after aether1054, for the resets that remained after #1064 on talos (#1054, the drain-start cluster). Not proposed upstream from here.

The mechanism

Once a hot-restart parent stops accepting new QUIC connections (drain start), quiche's dispatcher calls Envoy's OnFailedToDispatchPacket hook for every packet whose connection ID has no live session, and Envoy's override reports the packet as not dispatched so the listener forwards it to the child. That hook runs before quiche's own time-wait check (quic_dispatcher.cc, MaybeDispatchPacket: OnFailedToDispatchPacket on one line, IsConnectionIdInTimeWait on the next). So a packet for a connection the parent has just closed, which outside a hot restart the parent's time-wait manager answers with its stored CONNECTION_CLOSE, is instead forwarded to the child. The child has neither a session nor a time-wait entry for it: ValidityChecks → MaybeResetPacketsWithNoVersion → a stateless reset to the source, from the child, for a parent-owned connection ID, with the child's listeners still paused. That is the drain-start "second both-readers window" from the #1064 talos run: it needs nothing but a parent close while the source still has packets in flight, which under continuous load is every GOAWAY-driven close (response-time drain-closes and the aether1054 idle-drain timer). It also fits the pre-patch baseline (a few resets per run from gradual drain-closes), why immediate drain made it worse on talos (more parent closes in the window), and why kind's sparse traffic never showed it.

The change

EnvoyQuicDispatcher::OnFailedToDispatchPacket, while not accepting: if the destination connection ID is in the time-wait list, return false so quiche handles it as in normal operation (re-sends the stored CONNECTION_CLOSE for a connection this parent closed; a stateless reset only for one the peer itself already closed). Only genuinely unknown connection IDs keep being forwarded to the child. Behind envoy.reloadable_features.quic_hot_restart_time_wait_before_forward (default true; the lookup only runs on the draining path). Parent-side, so it takes effect from the second roll after deploy: the first roll's parent is the old binary.

Test

envoy_quic_dispatcher_test.cc ProcessPacketHandlesTimeWaitConnectionLocallyWhenNotAccepting: create a session from a CHLO, close it from our side (its ID enters time-wait with a CONNECTION_CLOSE), stop accepting, then a late packet for that ID is handled locally (processPacket true, nothing forwarded) while a packet for an ID this dispatcher never had is still forwarded (false). Red without the patch: the time-wait packet is reported as not dispatched. ProcessPacketForwardsTimeWaitConnectionWhenGuardDisabled covers the guard.

The test runs in the Envoy workspace only (both new cases pass for IPv4 and IPv6, with the QUIC and hot restart integration tests): like every @envoy//test/common/quic target it needs quiche's test tooling, which this downstream module does not wire up, so it is not in //bazel/patches:carried_patch_tests. The suite's other seven targets pass in proxy/ with the patch applied.

What the talos run should show

From the second proxy roll on: source-side Received_stateless_reset at drain start → 0, and the sources' QUIC close code for those connections becomes the parent's own CONNECTION_CLOSE (QUIC_NO_ERROR, "Closed by application") rather than a reset. If resets persist on rolls where the parent already runs this build, the remaining cause is not a parent-closed connection; one roll with --component-log-level quic:debug,connection:debug on the destination proxy would then give the CID match.

🤖 Generated with Claude Code

https://claude.ai/code/session_01WyMzptZ12rAgMW8cXtKqE4

…time-wait QUIC connections instead of forwarding them to the child (#1054)

Carries envoy-aether1054b-quic-time-wait-before-forward.patch on the
726d7ac pin, after aether1054. Once the parent stops accepting new QUIC
connections it forwarded every packet without a live session to the
child, before quiche's own time-wait check, so packets for connections the
parent had just closed reached the child, which never knew them and
answered with a stateless reset (the drain-start resets left after
#1064). EnvoyQuicDispatcher::OnFailedToDispatchPacket now leaves
connection IDs in the time-wait list to the time-wait manager, which
re-sends the stored CONNECTION_CLOSE, and forwards only genuinely unknown
ones. Behind envoy.reloadable_features.quic_hot_restart_time_wait_before_forward.
Parent-side: effective from the second roll on.

Its test (envoy_quic_dispatcher_test) only builds in the Envoy workspace
(quiche test tooling), so it is not in //bazel/patches:carried_patch_tests.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WyMzptZ12rAgMW8cXtKqE4
Signed-off-by: Bruno Palermo <[email protected]>
@bpalermo
bpalermo merged commit 8b817ab into main Sep 29, 2026
25 checks passed
@bpalermo
bpalermo deleted the proxy/1054-quic-time-wait-before-forward branch September 29, 2026 14:24
bpalermo added a commit that referenced this pull request Sep 29, 2026
…1054) (#1068)

immediate made the #1054 stateless resets worse on talos-main (4/8/0 per
roll vs 1-3 per 3-roll run under gradual): more parent connections close
inside the drain window. The carried Envoy patches (#1064, #1066) are the
fix under gradual; immediate stays an explicit opt-in. Chart 1.0.10.


Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr

Co-authored-by: Claude Opus 5.5 <[email protected]>
bpalermo added a commit that referenced this pull request Sep 29, 2026
…ger reads the parent's socket (#1054) (#1069)

Carries envoy-aether1054c-paused-udp-listener-no-read.patch on the 726d7ac
pin, after aether1054b. A child UDP listener built on an inherited socket
is paused until the parent is gone, but its read handler did not know:
when the QUIC listener injected a read activation to process handshakes
buffered from forwarded packets, the handler read the shared socket and
dequeued the parent's packets, which the child's dispatcher answered with
stateless resets (the drain-start resets left after #1064 and #1066). The
handler now runs the read-ready hook and returns without reading while
paused. Child-side, effective from the first roll. Test in
udp_listener_impl_test (red without the patch), in
//bazel/patches:carried_patch_tests. An upstream bug; proposed upstream
separately.


Claude-Session: https://claude.ai/code/session_01WyMzptZ12rAgMW8cXtKqE4

Signed-off-by: Bruno Palermo <[email protected]>
Co-authored-by: Claude Fable 5.1 <[email protected]>
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.

1 participant