Skip to content

proxy: carried patch — hot-restart child waits for the parent's exit before unpausing UDP listeners; idle HTTP/3 connections drain on GOAWAY (#1054) - #1064

Merged
bpalermo merged 1 commit into
mainfrom
proxy/1054-http3-goaway-on-drain
Sep 29, 2026

Conversation

@bpalermo

Copy link
Copy Markdown
Owner

Carries proxy/bazel/patches/envoy-aether1054-hotrestart-terminate-wait-h3-goaway.patch on the 726d7ac pin, after 47743 and aether1050, for #1054. Two changes, in the order the validator asked for after the config mitigation made the resets worse (#1054, latest comment): the both-readers window first, the HTTP/3 GOAWAY-on-idle second. Neither is proposed upstream from here.

1. Inherited UDP listeners stay paused until the parent has exited (primary)

The window. HotRestartingChild::sendParentTerminateRequest completed the drains (allDrainsImplicitlyComplete()), which unpauses the child's inherited UDP listeners, before sending Terminate. Those listeners are the parent's own sockets; the parent's workers keep reading them until the parent's shutdown stops them. For the length of that shutdown both processes dequeue from the same socket, and a packet for a parent-owned QUIC connection that the child reads first is an unknown connection to the child's dispatcher: MaybeResetPacketsWithNoVersion answers with a stateless reset, which the source accepts (the token is FNV1a_128(CID), no secret, so parent and child compute the same one).

The change. Terminate is sent first; the drains complete when the parent has actually exited. Nothing tells the child when the parent's workers stop, but the parent's domain socket refusing a datagram (ECONNREFUSED on the TestConnection probe that aether1050 introduced) tells it the parent process has exited, which is later. So after Terminate the child probes on a dispatcher timer every 50 ms and completes the drains on the first refusal, or after a 2 s cap so a parent that lingers cannot keep the listeners paused for long. Packets queue in the kernel meanwhile. A parent that is already gone when asked to terminate (the Terminate send itself is refused) needs no wait. The wait runs on a timer, not a blocking loop, so the child's main thread is never stalled during the most sensitive moment of the restart.

Test (red without, green with). hot_restarting_child_test.cc DrainsCompleteOnlyAfterParentHasExited: registered drained callbacks must not run when Terminate is sent (Times(0)), nor after a probe the parent still answers, and must run once a probe is refused; a callback registered mid-wait waits too. Without the patch the callbacks fire on the Terminate send, which trips the Times(0). Companions: DrainsCompleteAtTheCapIfParentLingers (cap at 0: the next probe completes the drains with a warning) and DrainsCompleteImmediatelyIfParentIsAlreadyGone (no timer). The existing terminate tests were updated to drive the probe.

2. HTTP/3 connections drain themselves inside the drain window, even when idle (secondary)

The HCM's drain notification (onDrain) only records the event; the only place a GOAWAY is sent on a server drain is encodeHeaders, when shouldDrainClose() wins (a coin flip weighted by elapsed/drain-time under Gradual). An idle HTTP/3 connection never gets one, so the source keeps it until the parent exits. (Idle HTTP/2 connections have the same gap; only the QUIC consequence, the stateless reset, is what hurts here, so only HTTP/3 is pushed.)

The change (ConnectionManagerImpl, behind envoy.reloadable_features.http3_drain_idle_connections, default on; requires the existing use_connection_event_drain). On the drain notification the HCM arms a timer: Immediate strategy fires now; Gradual picks a uniform point in [0, drain_time − drain_timeout − elapsed], so the GOAWAY and the close both land before the window ends, measured from the drain's start (which may predate the connection). When it fires, an HTTP/3 connection that is not already draining runs the normal startDrainSequence() (GOAWAY now, close after drain_timeout) and counts downstream_cx_drain_close. The codec is checked at fire time (the notification can arrive before the codec exists, from the connection's constructor); a connection with no codec yet is left to the regular decision on its first response. HTTP/1 and HTTP/2 connections are untouched.

Tests. conn_manager_impl_test_3.cc: immediate → timer at 0, shutdownNotice once, then goAway and close on the drain timer; gradual → timer inside the window (600 s drain, 100 ms timeout, 100 s elapsed, random 1000000 → 198 ms); window already passed → 0; already draining → no second sequence; HTTP/2 → no timer; no codec yet → no GOAWAY; guard off → no timer. quic_http_integration_test.cc IdleConnectionGetsGoAwayOnGracefulDrain: one request, then the connection idles, POST /drain_listeners?graceful, the server drain-closes it on its own and the client saw the GOAWAY before the disconnect (red without: the client only sees the listener-stop close, sawGoAway() false).

Compatibility

Wire protocol and HOT_RESTART_VERSION unchanged. Change 1 is child-side only and works against an unpatched parent (it only needs the parent's socket to disappear on exit). Change 2 is per-connection HCM behavior.

Delivery

All //bazel/patches:carried_patch_tests targets pass in proxy/ (the four hot-restart targets, plus @envoy//test/common/http:conn_manager_impl_test added for this patch). The patch's quic_http_integration_test case cannot build in this downstream module (quiche's test tooling needs Envoy's platform test headers), so it was verified in the Envoy workspace, where it and //test/integration:hotrestart_test pass on the patched tree.

For the sparse-mode harness (HR_MODE=sparse, idle timeout back at 30 s): expect source-side Received_stateless_reset = 0 per restart; child log line hot restart parent has exited; completing the drain from it on every roll (info), and hot restart parent has not exited ...ms after being asked to terminate (warn) only if the parent lingers past 2 s; http.*.downstream_cx_drain_close on the parent now counts the idle HTTP/3 connections too.

🤖 Generated with Claude Code

https://claude.ai/code/session_01WyMzptZ12rAgMW8cXtKqE4

…before unpausing UDP listeners; idle HTTP/3 connections drain on GOAWAY (#1054)

Carries envoy-aether1054-hotrestart-terminate-wait-h3-goaway.patch on the
726d7ac pin, after aether1050. Two changes for #1054:

1. The hot-restart child completed its drains, and so unpaused its
   inherited UDP listeners, while asking the parent to terminate. Those
   are the parent's own sockets, read by its workers until it stops, so
   both processes dequeued from them during the parent's shutdown and a
   parent-owned QUIC packet read first by the child got a stateless
   reset. The child now sends Terminate first and completes the drains
   once the parent's domain socket refuses a probe (50 ms timer, 2 s
   cap), or at once if the parent is already gone.

2. An HTTP/3 connection notified of a drain starts its own drain
   sequence (GOAWAY, then close) inside the drain window even when idle,
   instead of only when a response happens to be encoded. Behind
   envoy.reloadable_features.http3_drain_idle_connections.

Tests run from //bazel/patches:carried_patch_tests (hot_restarting_child_test
DrainsCompleteOnlyAfterParentHasExited is red without the patch;
conn_manager_impl_test Http3IdleConnection*). The patch's
quic_http_integration_test case only builds in the Envoy workspace.

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 ff6d713 into main Sep 29, 2026
25 checks passed
@bpalermo
bpalermo deleted the proxy/1054-http3-goaway-on-drain branch September 29, 2026 12:01
bpalermo added a commit that referenced this pull request Sep 29, 2026
…time-wait QUIC connections instead of forwarding them to the child (#1054) (#1066)

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.


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

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