Skip to content

UDP is not hitless across an Envoy hot restart: 10–15 s of UDP loss per node on every proxy roll (TPROXY capture, rev239 soak) #967

Closed

Description

@bpalermo

Found by the 2026-09-26 8h soak on rev239 (chart 0.94.0-d526bf2, the first TPROXY-capture run; proposal 038, #947).

What: the 5 udp-dialer pods (e2e/soak/udp.yaml, one 20-datagram cycle per ~5 s against the udp-echo UDPRoute on VIP:18082) lost 75 cycles in total out of ~28,780, and every increment falls 1–3 minutes after one of the 6 aether-proxy rolls (fleet-wide fails per roll: 11, 14, 14, 11, 14 (triple), 11). Zero at the agent-only, mesh-dns, edge and svc rolls, zero in the 19:16–20:46 no-roll window, and udp-echo was never rolled — the proxy hot restart is the only cause. Per node that is 2–3 cycles ≈ 10–15 s of UDP loss per proxy roll.

Why (as understood): the UDP capture listener is a transparent udp_proxy socket on :18082 in each pod netns; its sessions live in the old Envoy process. The hot-restart handoff carries the listening socket to the successor (reuse_port group) but not the udp_proxy session state, so in-flight sessions on the old process see their replies dropped while it drains, and a new session on the successor only starts when the dialer's next datagram lands there. The TCP paths are hitless on the same rolls (prober 0/2.16M errors), so this is UDP-specific.

Not tracked anywhere: e2e/soak/README.md ("The UDP leg") calls a fail that climbs only in the minute bracketing a proxy roll "the known shape", and the rev239 deploy note recorded it, but no issue owns it. The rev239 soak was graded PASS-WITH-FINDINGS with this as the finding.

Decision needed: accept it (document: "UDP sessions are not carried across a proxy hot restart; clients must tolerate ~15 s of loss per roll") or fix it. Fix directions, unverified: shorten the old process's UDP drain so the successor takes the flow sooner (the parent keeps answering the reuse_port group's share of datagrams while it drains); or make the supervisor's successor_wait gate on the UDP listener too; or move the dialer/client contract to "retry across a 20 s gap" and record that as the mesh's UDP SLO. Envoy's hot restart has no UDP session transfer, so full hitlessness would need the successor to own the socket exclusively before the parent stops answering.

Evidence: churn log /tmp/soak-churn.log (roll timestamps), dialer AETHER_METRIC udp_dialer={...} tallies, envoy_udp_capture_udp_udp_dialer_*_downstream_sess_{rx,tx}_datagrams_total (rx/tx exactly 1.0 outside the roll brackets).

Activity

  1. bpalermo commented on Sep 26, 2026

    @bpalermo
    OwnerAuthor

    Source analysis at the pin (726d7ac), from the envoy session, 2026-09-26. Three of my four hypotheses are not what happens; two real mechanisms remain, with file:line.

    Ruled out:

    • Failed netns socket inheritance / reuse_port split — socket passing is netns-aware end to end (hot_restarting_child.cc:128-149, hot_restarting_parent.cc:170-202, address_impl.cc:175-179); every child worker gets a dup of the parent worker's socket. #47492 only bites when the pod netns is gone.
    • IP_TRANSPARENT on the inherited fd — inherited UDP sockets are built with bind_to_port=false; only setListenSocketOptions runs and re-applies the PREBIND options on the existing fd (listen_socket_impl.h:79-89); idempotent.
    • UDP listeners closed at drain — maybeCloseSocketsForListener closes sockets only for non-UDP listeners (listener_manager_impl.cc:1386-1394); ActiveRawUdpListener::shutdownListener keeps reading during a hot-restart drain (active_udp_listener.h:102-113). Since envoy#46502 (in the pin, guard envoy.reloadable_features.udp_hot_restart_session_handoff default true) the draining parent serves the sessions it already has and forwards datagrams of unknown sessions to the child over the hot-restart RPC (active_udp_listener.cc:125-129, hot_restarting_parent.cc:68-80).

    Real:

    • M1 — the child's inherited UDP socket is paused until the child itself terminates the parent. UdpListenerImpl starts paused when the socket carries a parent-drained registrar (udp_listener_impl.cc:39-50), which every inherited UDP socket does (listener_manager_impl.cc:384-389); it unpauses only from allDrainsImplicitlyComplete (hot_restarting_child.cc:199-207), called at startup without a parent or inside sendParentTerminateRequest (hot_restarting_child.cc:230-234), i.e. --parent-shutdown-time-s after the child's workers start (drain_manager_impl.cc:218-232). The parent sends nothing on SIGTERM (hot_restarting_parent.cc:150). So if anything other than the child's own timer ends the parent, the shared socket has no reader until that timer fires. TCP is unaffected: inherited TCP sockets are never paused.
    • M2 — the forwarding registry is namespace-blind, and every pod's capture listener is 0.0.0.0:18082 in its own netns. UdpForwardingContext::registerListener keys on address->asString() = ip:port (hot_restarting_child.cc:13-19, address_impl.cc:139,152); the parent forwards with urlFromDatagramAddress of the datagram's destination (utility.cc:49-55) — namespace-less and, on a transparent socket, the VIP — so the child's lookup falls through to the 0.0.0.0:18082 default entry (hot_restarting_child.cc:24-43), where try_emplace kept only the FIRST registered pod's listener (the ASSERT is debug-only). Every forwarded datagram from any pod's parent listener is injected into the first-registered pod's listener in the child: wrong udp_proxy instance, wrong stat prefix, reply sent from a socket in the wrong pod netns. Window: child workers start → parent exit, new flows only, every pod but the first. This is an Envoy bug independent of the supervisor, and it is cross-pod misdelivery.

    aether-side facts that bear on which one it is:

    • The supervisor does NOT end the parent in a DaemonSet roll: the old pod's SIGTERM lands on the handoff branch ("admin LIVE at a NEWER epoch → wait for its parent-shutdown protocol", hotrestart/supervisor.go), bounded by successorWaitBudget = 180 − (45 + grace) − margin ≈ 120 s > --parent-shutdown-time-s 60. So on paper the child's own timer terminates the parent and M1's dark window should not exist — unless a roll takes another branch.
    • The soak dialer is nc -u per datagram (e2e/soak/udp.yaml): every cycle is a new flow, so during the overlap every dialer datagram takes the forwarding path — M2's exact shape. But M2 predicts losses for the whole ~60 s overlap (≈12 cycles) on every pod but one, and the soak lost 2–3 cycles per node per roll. Something bounds it; the timeline will say what.

    Next: E1 without any config change — reconstruct two rolls from the shipped logs (supervisor events per node: successor workers start, parent terminate; dialer NOREPLY timestamps) and place the loss window on that timeline. Then E2 (udp_hot_restart_session_handoff=false in the bootstrap runtime layer: parent serves everything locally until exit; if the loss shrinks to what M1 explains, M2 was contributing) and E3 (during a roll, the first-registered pod's capture_udp_* shows sessions for peers that belong to other pods). Upstream candidates, both real: (a) key the forwarding registry on address + namespace and forward the listener's bind address + namespace instead of the datagram's destination; (b) unpause inherited UDP sockets when the parent goes away (parent sends a terminating message from its SIGTERM path).

  2. bpalermo commented on Sep 26, 2026

    @bpalermo
    OwnerAuthor

    E1 done — read-only reconstruction of the 14:52 and 16:52 proxy rolls from the shipped supervisor/Envoy logs (VictoriaLogs) and the dialer's capture-listener counters. Two corrections to my previous comment and one answer.

    1. The real flags on talos are --drain-time-s 10 --parent-shutdown-time-s 15 (proxy.hotRestart.{drainTime,parentShutdownTime} in the chart, not the supervisor's 45/60 code defaults). The overlap is 15 s, which is the loss window.
    2. The child's own parent-shutdown timer ended the parent on all 10 node-rolls (shutting down parent after drain → parent shutting down due to child request 1–5 ms later, 14.95 s after starting workers); 9/10 old supervisors never took a SIGTERM branch (newest epoch terminated cleanly by successor; awaiting pod deletion), the one SIGTERM mid-overlap took handoff and waited. So the supervisor is not the terminator, and M1's "supervisor kills the parent early" variant is not what happens here.

    The answer: the loss window is exactly [child starting workers, parent terminate] — 28 of the 30 cycles that model predicts were lost across the 10 node-rolls (the 2 misses are edge cycles ≤2 s before the terminate), none outside it. And the datagrams are held, not misdelivered: the dialer's own capture_udp_udp-dialer-* counters stay flat through the overlap, then at parent-terminate jump by exactly (failed cycles + 1) on all 10 node-rolls (1→5, 2→5, 1→4…), with rx == tx == sess_total — every held datagram is answered by the child, on the right pod's listener, 2–14 s late; nc -w 1 has long given up. Nothing counted them during the overlap: the parent is not serving new flows, and the child's inherited socket is paused until it sends the parent-terminate (M1's mechanism, applied to the overlap itself). M2 (namespace-blind forwarding into the first-registered pod's listener) is ruled out as the cause: w03's dialer listener WAS the first capture_udp_* registered in the child on both rolls and still lost 2–3 cycles, and no other pod's capture_udp_* series ever appeared (misdelivery would have counted on the wrong prefix).

    Untested risk from this: the held datagrams sit in the shared socket's kernel receive queue for up to 15 s; heavier UDP load could overflow it and turn delay into loss.

    Aether-side consequence: shortening parentShutdownTime shrinks the window linearly (it is already 15 s); making UDP hitless needs the child to serve the inherited socket during the overlap, i.e. the Envoy side. Per-node tables, LogsQL and PromQL are in the session record; the Envoy side is being handled separately.

  3. added 2 commits that reference this issue on Sep 26, 2026
  4. bpalermo commented on Sep 26, 2026

    @bpalermo
    OwnerAuthor

    Fix A (envoyproxy/envoy#47743) validated on talos-main, 2026-09-26 23:37–23:57Z — it eliminates the loss.

    Build: chart 0.95.1-441aa98, proxy image with #47743 carried as a patch on the 726d7ac pin (#970, bot pin #971). Method: the 5 udp-dialer pods (one nc -u cycle per ~5 s, a NEW flow each cycle) tallied before and 4 min after each aether-proxy DaemonSet roll; each roll confirmed as a real hot restart per node from the proxy log (child starting workers → child shutting down parent after drain ~18 s later; drain 10 s / parent-shutdown 15 s).

    roll parent → child w01 w02 w03 w04 w05 fleet
    1 — the deploy (control) unpatched → patched +3 +3 +3 +3 +3 15
    2 — rollout restart patched → patched 0 0 0 0 0 0
    3 — rollout restart patched → patched 0 0 0 0 0 0

    Every rev239 roll (6 of them, 2026-09-26 soak) and the control roll lost 2–3 cycles per node (11–15 fleet-wide); two consecutive patched-to-patched rolls lost none. The control behaves exactly as predicted for a mixed pair: the unpatched parent still forwards only the datagram destination, so the child takes the old destination-based lookup. Prober and the QUIC twins (upstream_cx_connect_fail) showed no errors across any of the three rolls; every proxy pod at 0 restarts.

    This corrects my E1 reading: the datagrams sent during the overlap were going through the forwarding path after all (the "held then answered late on the right listener" signature was the misdelivered datagram's session being re-established once the child unpaused), so keying the registry by listener address + network namespace is what makes UDP hitless across the handoff. Fix B is not needed for this loss.

    Remaining for #967: the patch is carried in aether's proxy build until the pin moves past the merged upstream PR; the UDP leg of the next soak grades against 0 fails per proxy roll from now on.

  5. bpalermo commented on Sep 27, 2026

    @bpalermo
    OwnerAuthor

    Closing: fixed by envoyproxy/envoy#47743, carried as a patch on the proxy's 726d7ac pin (#970, bot pin #971, on talos-main since chart 0.95.1 / helm rev241) and validated on 2026-09-26 with three measured aether-proxy DaemonSet rolls — the mixed unpatched→patched control lost 3 udp-dialer cycles per node (15 fleet-wide, the same shape as all six rev239 rolls), two patched→patched rolls lost 0 on every node; the 0.95.3 deploy roll on 2026-09-27 lost 0 again. The soak README now grades the UDP leg at 0 fails per proxy roll (#976). The carried patch is dropped when a plain pin contains the merged upstream PR (tracked with the other carried patch in the successor to #957).

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions