Skip to content

QUIC: 1–2 requests per proxy roll fail with a stateless reset from the successor (upstream_reset {QUIC_PUBLIC_RESET|FROM_PEER|Received_stateless_reset}) when the parent exits with h3 connections still carrying traffic #1054

Closed

Description

@bpalermo

Seen on every measured roll set today (talos-main, 300 rps of k6 to the two QUIC twins):

  • rev248 phase C, roll 4 (16:25:44Z): 2 × 503 UC upstream_reset_before_response_started{connection_termination|QUIC_PUBLIC_RESET|FROM_PEER|Received_stateless_reset.} at 16:26:50 and 16:27:46 (w05, w01 → svc-1@aether-test/default).
  • rev249 e2e, proxy roll 3 (18:19:56Z): 1 × 200 UC upstream_reset_after_response_started{…QUIC_PUBLIC_RESET|FROM_PEER|Received_stateless_reset.} at 18:21 — the client (k6) saw it as status=0 (read error) even though the proxy logged 200.

h2 destinations through the same rolls: 0. The DC race (#1009) is a different, benign shape.

Mechanism (from the #1050 analysis, Envoy 726d7ac): during the parent-shutdown window the parent forwards packets it has no session for to the child, and the child's UDP listeners stay paused until the parent terminates. Connections owned by the parent keep being served by the parent until it exits (--drain-time-s 10, --parent-shutdown-time-s 15). When the parent exits, packets for those connection IDs land on the child, which knows nothing about them and answers with a stateless reset → the source's h3 pool sees FROM_PEER Received_stateless_reset and fails the in-flight request. h2 has no equivalent because the parent's TCP connections are drained with GOAWAY and closed before exit.

Ask: make the parent's h3 connections drain gracefully before exit — send HTTP/3 GOAWAY + CONNECTION_CLOSE on drain so the source pool opens new connections on the child before the parent goes away (check whether drain_listeners?graceful reaches EnvoyQuicServerConnection / QuicHttpServerConnectionImpl::shutdownNotice at the pin, and whether the destination's QuicDownstreamTransport/listener needs enable_graceful_drain-style config). If Envoy cannot, the upstream shape belongs with the #1050 note. Gate: per-roll count of Received_stateless_reset on sources = 0 (add to the soak README next to the #1050 gates).

Related: #1050, #1009, #967, #979 (handoff gate).

Activity

  1. added
    bug
    on Sep 28, 2026
  2. bpalermo commented on Sep 28, 2026

    @bpalermo
    OwnerAuthor

    Mechanism and fix plan (Envoy 726d7ac + carried 47743/aether1050; quiche 7f07dc4)

    Why sources see a stateless reset. sendParentTerminateRequest (patched hot_restarting_child.cc:326-337) calls allDrainsImplicitlyComplete() before sending Terminate, which unpauses the child's inherited UDP listeners (udp_listener_impl.cc:39-57) while the parent's workers still read the same sockets until its SIGTERM → stopWorkers. In that window a packet for a parent-owned CID read by the child is an unknown short-header packet → MaybeResetPacketsWithNoVersion (quic_dispatcher.cc:1486-1531) → stateless reset. The source accepts it: the token is FNV1a_128(CID) with no secret (quic_utils.cc:514-523), identical on parent and child. (A clean parent exit would have produced PEER_GOING_AWAY instead.)

    Why the parent's connections are still live at exit. Drain reaches the QUIC sessions (EnvoyQuicDispatcher::drainAllConnections, envoy_quic_dispatcher.cc:244-265) but ConnectionManagerImpl::onDrain (conn_manager_impl.cc:731-735) only records the event; GOAWAY is sent only from encodeHeaders when shouldDrainClose() wins, which under the default Gradual strategy is a coin flip weighted by elapsed/drain-time. Idle connections, and busy ones that lose every flip, get no GOAWAY. The source's h3 pool does drain on GOAWAY (envoy_quic_client_session.cc:195-201); it just never gets one. UpstreamIdleTimeout 30 s > the 15 s parent-shutdown window keeps idle twin connections alive until exit.

    Source retry won't help: outboundRetryPolicy (route.go:65-67) connect-failure,refused-stream,reset-before-request,503 doesn't match (request already sent); adding reset is unsafe for non-idempotent requests and after_response_started is never retryable.

    Plan

    1. Config (first): --drain-strategy immediate via a chart value → --envoy-arg, so every response after drain start carries GOAWAY; and an 8 s idle timeout on the h3 twin pools only (Http3ProtocolOptions), enforced as quicIdle + 5 s < parentShutdownTime by an agent flag the chart fills. h1/h2 keep 30 s.
    2. Carried Envoy patch (long-term; lets the idle cut be undone): envoy-aether1054-http3-push-goaway-on-drain.patch — in ConnectionManagerImpl::onDrain, for an HTTP/3 codec arm a timer (onDrain may only record, connection_impl_base.cc:23): 0 for Immediate, random in [0, drainTime − drain_timeout) for Gradual; on fire, if not already draining, startDrainSequence() + downstream_cx_drain_close_. Runtime-guarded. Optional companion: delay allDrainsImplicitlyComplete() in sendParentTerminateRequest until the proxy: carried patch — non-blocking hot-restart UDP forwarding and bounded child receives (#1050) #1060 probe sees ECONNREFUSED (cap ~2 s) to close the both-readers window. Unit tests in conn_manager_impl_test_2.cc (immediate → shutdownNotice once; gradual → timer < drain time; h2/guard-off no-op; no double start) + quic_http_integration_test (idle h3 client sees GOAWAY after /drain_listeners?graceful with no request), wired into //bazel/patches:carried_patch_tests.
    3. Proof on kind: new sparse HR_MODE in e2e/eastwest-quic-hotrestart.sh (busy curl loops don't reproduce it): stop loops at SIGHUP, one request at T+2, then a 1 s burst (~200 req, c=20) timed on the parent's shutting down due to child request; 10 restarts; count source-side Received_stateless_reset and PEER_GOING_AWAY per restart. Red: current chart. Green: 0 per restart for the config fix, and separately for the patch with idle back at 30 s; hotrestart-wedge.sh still 0 wedges.
    4. Soak gate: per roll, source Received_stateless_reset = 0 and QUIC 503 UC = 0. Don't gate on the destination's quic.dispatcher.stateless_reset_packets_sent (inflated by the draining parent forwarding its own time-wait CIDs, quic_dispatcher.cc:493-503).

    Risks: immediate drain is server-wide (h2+h3 reconnections bunch at drain start → child handshake CPU spike; also changes LDS and pod-termination drains); the 8 s h3 idle timeout costs extra QUIC handshakes for pairs idle 8–30 s (#1006 figures); a request in flight at parent exit still dies, as with h2.

  3. bpalermo commented on Sep 28, 2026

    @bpalermo
    OwnerAuthor

    Reopening: #1063 merged with Closes before its body was switched to Refs. The kind red arm reproduced only 1 reset in 10 forced restarts, so kind zeros are weak evidence. This closes on the talos gate instead: 0 source-side Received_stateless_reset and 0 QUIC 503 UC across the e2e proxy rolls on the #1063 build.

  4. bpalermo commented on Sep 28, 2026

    @bpalermo
    OwnerAuthor

    Talos result for the config fix (#1063, chart 1.0.7-4c72e23): it does NOT fix #1054 — resets went up

    Live config verified: --drain-strategy immediate in Envoy's command line, --east-west-quic-idle-timeout=8s on the agent. Same short e2e as before (300 rps k6 to the QUIC twins, agent roll, then proxy rolls at 23:31, 23:38, 23:47Z):

    roll source-side 503 UC … Received_stateless_reset
    1 (23:31) 4 (w03, w04, w05 ×2 → svc-2 twin)
    2 (23:38) 8 (5 nodes, svc-1 + svc-2 twins)
    3 (23:47) 0 so far

    For comparison, the whole 3-roll runs on rev249/rev250/rev251/rev252 had 1–3 resets total. Zero PEER_GOING_AWAY, zero watchdog/drain-kill lines.

    Reading: the GOAWAY-based config attacks the "idle connection outlives the parent" half, but the resets come from the both-readers window (the child unpauses its inherited UDP listeners in sendParentTerminateRequest before the parent's workers stop), and immediate drain appears to put more live connections into that window at once (every source reconnect/close happens at drain start instead of being spread). The direct fix is the companion in the carried patch: delay allDrainsImplicitlyComplete() until the parent is actually gone (the #1060 probe's ECONNREFUSED, capped), so the child never reads a parent-owned CID. Recommend reverting drainStrategy to gradual (keep the 8 s twin idle or not — it made no visible difference) until that patch lands.

  5. bpalermo commented on Sep 29, 2026

    @bpalermo
    OwnerAuthor

    Roll 3 (23:47Z) finished with 0 resets. Final for the config fix on talos: 4 / 8 / 0 across the three rolls, 12 total, versus 1–3 per whole run before it. The 8 × 0/DC at 00:05Z are k6 connections cut at the runner teardown, not a roll.

  6. bpalermo commented on Sep 29, 2026

    @bpalermo
    OwnerAuthor

    Kind red/green for the carried patch (envoy session, 13a601c): PASS

    Two kind nodes, HR_MODE=sparse, 10 restarts per arm, live config read back per arm. A real red needed --skip-hot-restart-parent-stats plus a 2 s parent freeze spanning Terminate (otherwise the frozen parent also blocks the child and Terminate always lands after the freeze):

    arm proxy drain / twin idle stateless resets
    R1s unpatched gradual / 30 s 42 (3, 19, 18 on the 3 restarts where the freeze spanned Terminate, +2)
    G1s patched gradual / 30 s 0 (freeze spanned Terminate 7/10; the child waited 640–740 ms for the parent)
    G2 patched gradual / 30 s, unforced 0
    G3s patched immediate / 8 s 0
    R3s unpatched immediate / 8 s 0
    W patched hotrestart-wedge.sh WEDGE_FREEZE_S=6 wedges 0/8 (#1060 holds)

    parent has exited; completing the drain on every patched roll; the 2 s cap warning never fired. Parent exits 32–48 ms after Terminate unloaded, 136–173 ms under load.

    On kind the config mitigation alone also removes the forced resets (R3s = 0), so the talos increase (4/8/0) needs something kind's sparse load lacks. The talos e2e with the patch and gradual drain (so the patch is the only lever) is the deciding test.

  7. bpalermo commented on Sep 29, 2026

    @bpalermo
    OwnerAuthor

    Talos e2e with the carried patch (#1064, chart 1.0.8-5be4a81, drain gradual, twin idle 8 s): resets NOT zero — and they are in a different window

    k6 300 rps to the QUIC twins, agent roll + 3 proxy rolls (12:47, 12:55, 13:04Z):

    roll source Received_stateless_reset PEER_GOING_AWAY
    1 0 0
    2 4 (12:55:07.77–.88) 0
    3 1 (13:04:07.77) 0

    Patch behaviour: hot restart parent has exited; completing the drain from it on every node every roll; the 2 s cap warning never fired; parent shutting down due to child request → child parent has exited = 0.26–0.54 s under load. No watchdog/drain kills.

    All 5 resets are from destination pods on main-worker-04 (svc-2 10.244.0.238, svc-1 10.244.0.239 — w04's pod CIDR), and they happen at the start of that node's hot restart, not at parent exit. Timeline on w04, roll 2:

    • 12:55:03.52 supervisor live predecessor confirmed; starting cross-pod hot restart (epoch 76 → 77)
    • 12:55:07.083 child all dependencies initialized. starting workers
    • 12:55:07.544 parent closing and draining listeners
    • 12:55:07.77–.88 the 4 resets
    • 12:55:22.18 parent exiting (Terminate path, 15 s later)

    So the both-readers window at Terminate is closed by the patch (0 resets there on any node), but a second window exists at drain start: within ~0.3 s of starting workers / closing and draining listeners some packets for parent-owned connection IDs are read by a child socket. Candidates: child QUIC listeners that got fresh reuse-port sockets instead of inherited ones (so the kernel's SO_REUSEPORT group hashes flows to the child immediately and the pause-until-parent-exits does not apply to them), or the parent's drain start itself resetting. The parent's hot_restart_udp_forwarding_{dropped,retries} counters are not exported to Prometheus (only server.hot_restart_{epoch,generation} are), so they can't answer it from here. Why only w04 (the first node rolled both times?) is open.

  8. bpalermo commented on Sep 29, 2026

    @bpalermo
    OwnerAuthor

    Talos e2e with #1066 (time-wait before forward) on top of #1064 — chart 1.0.9-0e54a6d, drain gradual

    Every graded roll ran a parent on the #1066 build (the deploy's own roll at 14:51–14:55 was the old-parent roll).

    roll resets where
    1 (15:06) 4 (15:08:00.89, 01.90, 02.10, 02.18) destinations on main-worker-04 again (svc-2 10.244.0.238, svc-1 10.244.0.239); sources w01 ×3, w03 ×1
    2 (15:14) 0
    3 (15:23) 0

    w04 timeline, roll 1: 15:07:55.72 cross-pod hot restart 79→80; 15:08:00.35 child starting workers; 15:08:00.73 parent closing and draining listeners; resets +0.16 to +1.45 s; 15:08:15.24 parent shutting down due to child request; 15:08:15.55 child parent has exited. No watchdog, no cap warning, zero PEER_GOING_AWAY, prober clean.

    So the time-wait patch did not remove the drain-start resets. The pattern across three runs is now very specific: always destination pods on main-worker-04, always within ~1.5 s of that node's drain start, never at parent exit, never on other nodes' svc-1/svc-2 pods (svc-1 also runs on w01/w02/w05, svc-2 on w01/w02/w03). Next step is the CID match proposed earlier: one roll with --component-log-level quic:debug,connection:debug on w04's proxy.

  9. bpalermo commented on Sep 29, 2026

    @bpalermo
    OwnerAuthor

    Closed on the talos gate — #1069 (paused UDP listener no longer reads the shared socket)

    Talos rev256, chart 1.0.11-9d983f5, proxy image 3814b097 (carried patches aether1050 + 1054 + 1054b + 1054c), drain strategy gradual by default (#1068), no overrides. Short e2e 17:43:35–18:29Z: k6 300 rps to the QUIC twins, agent roll under load, then 3 proxy rolls.

    result
    k6 792,003 requests, 0 failed (all five loaders http_req_failed_rate=0, 0 failure samples)
    source Received_stateless_reset per proxy roll 0 / 0 / 0 (first roll included)
    PEER_GOING_AWAY 0
    watchdog / drain-kill / terminate-wait cap warning 0
    prober 0 non-success of 223,893

    The only non-2xx lines in the window: 3 during the deploy itself (17:42–17:43, before k6 started) and 9 0/DC at 18:29 when the k6 runners were torn down.

    Every earlier talos run of the day had resets on at least one roll (rev249–252: 1–3 per run; rev253 immediate drain: 4/8/0; rev254 #1064: 0/4/1; rev255 #1066: 4/0/0), with the drain-start cluster on the load's destination pods. Root cause (envoy session): a paused child UDP listener still read the inherited socket whenever the parent forwarded a new connection's CHLO (activateRead() → handleReadCallback with no paused() check), so it dequeued parent-owned packets and answered them with stateless resets.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions