Skip to content

udp: a paused hot restart listener must not read the parent's socket - #47868

Merged
mattklein123 merged 4 commits into
envoyproxy:mainfrom
bpalermo:udp-paused-listener-no-read-main
Oct 13, 2026
Merged

mattklein123 merged 4 commits into
envoyproxy:mainfrom
bpalermo:udp-paused-listener-no-read-main

Conversation

@bpalermo

@bpalermo bpalermo commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Commit Message: udp: a paused hot restart listener must not read the parent's socket
Additional Description:

A UDP listener created from a socket inherited during a hot restart stays paused until the parent is gone (UdpListenerImpl, paused()): its read events are not enabled, the parent keeps serving the socket, and the packets that belong to the child arrive over the hot restart forwarding channel (#29585). That single-reader rule is what makes sharing the socket safe: a packet of a parent-owned QUIC connection dequeued by the child is an unknown connection to the child's dispatcher and gets a stateless reset.

The read handler did not know about the pause. When the parent forwards a new connection's first packet, ActiveQuicListener buffers the handshake and calls activateRead() on its listener to process buffered handshakes on the next loop iteration. An injected activation is delivered regardless of the enabled events (FileEventImpl::mergeInjectedEventsAndRunCb), and UdpListenerImpl::handleReadCallback then ran onReadReady(), which was the intent, and read the socket, which is the parent's. Under load this shows up as a burst of stateless resets on client connections to the parent right after the parent starts draining: each reset makes the client reconnect, the new handshake is forwarded, the read fires again, until every client has moved to the child. It needs new connections during the drain window (a forwarded handshake is the trigger), so it is invisible without traffic.

Fix: while paused, an injected read runs the read-ready callback and returns without reading the socket or re-arming the read. Unpausing is unchanged.

Testing: QuicHotRestartIntegrationTest.PausedListenerLeavesTheParentsPacketsOnTheSocket (new, test/integration/quic_hot_restart_integration_test.cc) runs a real server whose QUIC listener gets its UDP socket "inherited" from a parent the test plays: the test binds the socket, hands the server a duplicate through duplicateParentListenSocket, keeps the listener paused through the parent-drained registrar, and forwards packets through the listener's worker router as a parent does. With a packet of a parent-owned connection waiting on the shared socket, it forwards two new connections and waits for the server to answer both, then checks that the parent's packet is still on the socket and that its sender got no stateless reset; once the parent is drained, the same kind of packet reaches the server and is reset. Without the fix the listener dequeues the parent's packet (fails in both IP versions). To let a test supply the hot restart implementation, IntegrationTestServer::create takes an optional Server::HotRestart* (set from BaseIntegrationTest::hot_restart_; default unchanged). HotRestartedUdpListenerImplTest.InjectedReadWhilePausedDoesNotReadTheSocket covers the listener in isolation: the read-ready callback runs, the socket is not read and the read is not re-armed, and reading starts once the parent-drained callback fires. Existing pause tests, active_quic_listener_test, quic_http_integration_test and hotrestart_test pass. Verified on a deployment that reproduced the resets under HTTP/3 load across hot restarts, with socket inheritance confirmed correct beforehand.

Risk Level: low (hot restart child, paused UDP listeners only)
Testing: integration test (new), unit test (new), QUIC listener and integration tests, hot restart integration test, real deployment as described
Docs Changes: N/A
Release Notes: bug_fixes
Platform Specific Features: N/A

A UDP listener created from a socket inherited during a hot restart stays
paused until the parent is gone: its read events are not enabled, the
parent keeps serving the socket, and the packets that belong to the child
are forwarded over the hot restart channel. But the read handler did not
know about the pause. The QUIC listener injects a read activation on its
listener (activateRead()) to process the handshakes it buffered from
forwarded packets, injected activations are delivered regardless of the
enabled events, and the handler then read the socket, dequeuing packets
that belong to the parent's connections; the child's QUIC dispatcher
answered each with a stateless reset. Every reset made the client
reconnect, the new handshake was forwarded, and the read fired again,
until every client had moved to the child.

While paused, an injected read now runs the read-ready callback and
returns without reading the socket or re-arming the read.

Signed-off-by: Bruno Palermo <[email protected]>
@bpalermo

Copy link
Copy Markdown
Contributor Author

/retest

@mattklein123 mattklein123 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like a pretty core change and it seems like we should have better test coverage of this. Please figure out some integration test.

/wait

A real server runs its QUIC listener on a socket inherited from a parent
the test plays. A packet of a parent-owned connection must stay on the
shared socket while forwarded connections are served, and is read and
reset only once the parent has drained. Fails without the fix.

The integration test server takes an optional Server::HotRestart to make
this possible; the default is unchanged.

Signed-off-by: Bruno Palermo <[email protected]>
@bpalermo

bpalermo commented Oct 1, 2026

Copy link
Copy Markdown
Contributor Author

Added an integration test, QuicHotRestartIntegrationTest.PausedListenerLeavesTheParentsPacketsOnTheSocket: a real server whose QUIC listener runs on a socket "inherited" from a parent the test plays (the test owns the socket, hands the server a duplicate, keeps the listener paused and forwards new connections to it the way a parent does). It leaves a packet of a parent-owned connection on the shared socket, forwards two connections and waits for the server to answer them, then checks the packet is still there and its sender was not reset; after the parent drains, the server reads the socket and resets that kind of packet. It fails without the fix (the listener dequeues the parent's packet). The integration test server gained an optional Server::HotRestart* for this; the default is unchanged. Also merged main.

@bpalermo
bpalermo requested a review from mattklein123 October 5, 2026 14:34
RyanTheOptimist pushed a commit that referenced this pull request Oct 13, 2026
…estart parent drains (#48206)

Commit Message: quic: leave time-wait connections to the time-wait list
while a hot restart parent drains
Additional Description:

While a hot restart parent drains, its QUIC dispatcher stops accepting
new connections and `EnvoyQuicDispatcher::OnFailedToDispatchPacket`
reports every packet without a live session as not dispatched, so
`ActiveQuicListener` forwards it to the new process (#29585). That hook
runs before quiche looks at its time-wait list, so "no live session"
includes the connections this dispatcher has just closed itself, which
is most of them during a drain. A late packet for one of those (a
retransmission, or data sent before the peer saw the close) is forwarded
to the child, which never knew the connection and answers with a
stateless reset. Without the forwarding the parent's time-wait list
would have re-sent the stored `CONNECTION_CLOSE`, which tells the peer
why the connection ended.

Fix: while not accepting, a packet whose destination connection ID is in
the time-wait list is left to quiche (the hook returns false and the
dispatcher goes on to the time-wait list as usual). Only packets for
connections the dispatcher does not know at all are forwarded. The
change is in the parent, so it applies from the first hot restart in
which the draining process has it.

Runtime guard:
`envoy.reloadable_features.quic_hot_restart_time_wait_before_forward`
(default true).

Testing:
`EnvoyQuicDispatcherTest.ProcessPacketHandlesTimeWaitConnectionLocallyWhenNotAccepting`
creates a session, closes it with a `CONNECTION_CLOSE` so its ID is in
the time-wait list, stops accepting, and checks that a later packet for
that ID is handled by the dispatcher while a packet for an unknown ID is
still reported for forwarding.
`ProcessPacketForwardsTimeWaitConnectionWhenGuardDisabled` checks the
previous behavior with the guard off. `active_quic_listener_test`,
`quic_http_integration_test` and `hotrestart_test` pass.

Observed on a deployment running HTTP/3 under load across hot restarts,
as stateless resets around each restart. It was deployed there together
with #47868, which fixes the larger source of those resets (the paused
child listener reading the shared socket); this change has not been
measured in isolation from that one, so its own share rests on the
mechanism above and the unit tests.

Risk Level: low (QUIC listeners of a draining hot restart parent only;
runtime guarded)
Testing: unit tests (new), QUIC listener and integration tests, hot
restart integration test
Docs Changes: N/A
Release Notes: bug_fixes
Platform Specific Features: N/A
Runtime guard:
envoy.reloadable_features.quic_hot_restart_time_wait_before_forward

Signed-off-by: Bruno Palermo <[email protected]>
@mattklein123
mattklein123 merged commit 2eff6e8 into envoyproxy:main Oct 13, 2026
27 checks passed
@bpalermo
bpalermo deleted the udp-paused-listener-no-read-main branch October 26, 2026 20:42
bpalermo added a commit to bpalermo/aether that referenced this pull request Nov 1, 2026
…t under Bazel 9 (#1732)

* docs(proposals): 045, move aether-proxy to the Envoy 1.41 dev snapshot under Bazel 9

The pin moves from 1.40.0.envoy to 1.41.0-dev.20261028.011e396.envoy, the only
newer version the envoy bazel-registry publishes. It contains
envoyproxy/envoy#47868 and #47893, so aether1054c and aether1074 drop; 47740
and aether1126 stay as they are, aether1050 and aether1054 with their context
refreshed (aether1050 checked against #47068's change to the same receive
loop). The proxy workspace moves to Bazel 9.3.1 in the same change: the
1.40.0 closure does not load under Bazel 9. Lists the upstream changes that
touch aether (#45504, the TLS 1.3 client default, CDS warming, ODCDS, GRO) and
the validation: the proxy workflow, the Envoy-workspace tests, and an 8 h soak
before release.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01YacWmjoxWSZRJC38XYxuZx

* docs(proposals): 045, review fixes: cross-version hot restart, snapshot risk, release hold, TLS 1.3 probe

- Hot restart across 1.40.0 and 1.41-dev, both directions: the evidence that
  they interoperate (HOT_RESTART_VERSION 11 at both pins, hot_restart.proto and
  the IPC sources unchanged, #47068 the only receive-loop change, identical
  carried IPC patches), and a validation step rolling one node 1.40 -> 1.41 ->
  1.40 under the prober.
- The risk of a dev snapshot in production: no backport branch; fixes arrive
  by a later snapshot, the 1.41.0 release (the pin moves to 1.41.0.envoy when
  published) or a carried patch.
- QUICHE: #48288 (132bfd9) and #48484 (67bce2e, what ships).
- TLS 1.3 vs the connect-only inbound readiness probe: the failure mode from
  the upstream release note, and a pre-release mitigation (the probe pins TLS
  1.2, a separate agent PR). A TCP-routed soak check for the TLS version and
  the source identity.
- A release hold: proxy-release.yml publishes and arms auto-merge on the
  chart pin; the owner disables it and soaks the published digest first.
- Rollback: the guards are read only when a TLS context or listener is built;
  a static runtime layer plus a proxy roll is the lever, /runtime_modify is not.
- aether1733 (the validate-mode crash #1733's CI found) added to the patch
  set; the soak points to proposal 042 and the external harness; aether relies
  on hot_restart_propagate_stat_tags' default rather than setting it; the
  local-gate claims say what the sandbox could and could not run.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01YacWmjoxWSZRJC38XYxuZx

* docs(proposals): 045, aether1733: corrected production exposure, alternatives, upstream text

The validate-mode crash needs concurrency > 1 (the BPF reuseport option);
today's chart bootstraps have static clusters only, so production does not
crash today, but a future static QUIC listener would fail the supervisor's
pre-restart check and every hot restart. Records why the runtime guard and
--concurrency 1 were set aside, that the FilterState key rejection in the
same log is an expected negative case, and the upstream issue/PR text,
prepared for the owner to post.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01YacWmjoxWSZRJC38XYxuZx

* docs(proposals): 045, an enforceable release hold; a cluster-wide cross-version roll with QUIC traffic

- The hold is set up before #1733 merges: manual release mode (RELEASE_PAT
  removed from the `release` environment until the soak verdict, so
  proxy-release.yml opens, arms and supersedes no pin), a merge freeze on
  proxy/** (not *.md), bazel/registry/** and proxy-release.yml, and the
  fallback for an armed pin (disable auto-merge on it and on any superseding
  pin, which carries a different, unsoaked digest). Nothing else merges on its
  own: Dependabot opens no PRs, no Renovate, main.yaml only updates pin
  branches, and re-runs are covered by the freeze.
- Step 5 is a cluster-wide roll (1.40.0 -> candidate -> 1.40.0 -> candidate):
  a Helm image override rolls every node and the edge Deployment, DaemonSets
  have no partition, and OnDelete is no handoff. It needs QUIC traffic pinned
  across nodes and connections established before each roll, with per-handoff
  twin-cluster and inbound QUIC listener counters.
- The #45504 risk row names the validate-mode crash, aether1733 and
  envoy_validate_test; the Status line points at the hold; the test-unit
  wording is neutral.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01YacWmjoxWSZRJC38XYxuZx

* docs(proposals): 045, the soak validates the deployed full bump; no release hold

The owner decided on 2026-11-01 that the soak runs only after the full bump:
the release goes out through proxy-release.yml in its normal auto mode, and the
three-layer hold (manual mode, merge freeze, fallback) is removed.

- The cross-version hot restart is folded into the soak: a same-version
  baseline roll that is actually run, the upgrade (the deploy), the 8 h soak,
  then rollback and forward, all cluster-wide (the chart has no node-scoped
  proxy canary).
- Pass criteria that tell a clean handoff from a broken one: reset-aware
  increases (counters are per generation), forward progress on the destination
  inbound's downstream_rq_total and the source twin's upstream_rq_total,
  request failures (5xx, resets, cx destroyed with active requests, the load
  generator's errors) and prober misses bounded by the baseline's worst
  handoff; downstream_cx_total only as a diagnostic, since it counts new
  sessions.
- A QUIC destination on every node with a remote source, so every inherited
  listener carries traffic through its own handoff.
- The twin's stat key is <ns>/<svc>@<ns>/<sa> (QUICAltStatName), not quic:...
- Auto mode described accurately; rollback by reverting the pin or the
  implementation, and the static runtime layer for a behaviour.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01YacWmjoxWSZRJC38XYxuZx

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
bpalermo added a commit to bpalermo/aether that referenced this pull request Nov 1, 2026
…er1054c and aether1074 (proposal 045)

- envoy/envoy_api 1.40.0.envoy -> 1.41.0-dev.20261028.011e396.envoy, registry
  a1264b53 -> 36d481b01b (the commit that added the snapshot).
- Dropped patches: aether1054c (envoyproxy/envoy#47868, 2eff6e8ccf) and
  aether1074 (envoyproxy/envoy#47893, 77b512527c), both in the snapshot.
- aether1050 refreshed from envoyproxy/envoy#47834's head against its merge
  base, which already contains #47068: the +/- lines are unchanged, only the
  test file's context moved. aether1054 refreshed by hand: two one-line
  insertions whose neighbouring runtime guards were removed upstream. 47740
  and aether1126 apply unchanged.
- .bazelversion 8.7.0 -> 9.3.1 (Envoy's own; the 1.40.0 closure does not load
  under Bazel 9, so the move cannot land first). .bazelrc follows upstream:
  merge_fixed_and_default_shell_env removed, system_include_paths and the
  rules_rust linker_messages flags added, the toolchains_llvm compiler-rt and
  libunwind overrides dropped (the envoy module links compiler-rt + libunwind
  since envoyproxy/envoy#48641).
- proxy-wasm-cpp-host .envoy -> .envoy.1, rules_cc 0.2.25 -> 0.2.27,
  rules_python 2.3.3 -> 2.4.5: what the new closure selects.
- The MODULE.bazel comment that still called #47893 open is rewritten.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01YacWmjoxWSZRJC38XYxuZx
bpalermo added a commit to bpalermo/aether that referenced this pull request Nov 1, 2026
…er1054c and aether1074 (proposal 045) (#1733)

* proxy: Envoy 1.41.0-dev.20261028.011e396 under Bazel 9.3.1; drop aether1054c and aether1074 (proposal 045)

- envoy/envoy_api 1.40.0.envoy -> 1.41.0-dev.20261028.011e396.envoy, registry
  a1264b53 -> 36d481b01b (the commit that added the snapshot).
- Dropped patches: aether1054c (envoyproxy/envoy#47868, 2eff6e8ccf) and
  aether1074 (envoyproxy/envoy#47893, 77b512527c), both in the snapshot.
- aether1050 refreshed from envoyproxy/envoy#47834's head against its merge
  base, which already contains #47068: the +/- lines are unchanged, only the
  test file's context moved. aether1054 refreshed by hand: two one-line
  insertions whose neighbouring runtime guards were removed upstream. 47740
  and aether1126 apply unchanged.
- .bazelversion 8.7.0 -> 9.3.1 (Envoy's own; the 1.40.0 closure does not load
  under Bazel 9, so the move cannot land first). .bazelrc follows upstream:
  merge_fixed_and_default_shell_env removed, system_include_paths and the
  rules_rust linker_messages flags added, the toolchains_llvm compiler-rt and
  libunwind overrides dropped (the envoy module links compiler-rt + libunwind
  since envoyproxy/envoy#48641).
- proxy-wasm-cpp-host .envoy -> .envoy.1, rules_cc 0.2.25 -> 0.2.27,
  rules_python 2.3.3 -> 2.4.5: what the new closure selects.
- The MODULE.bazel comment that still called #47893 open is rewritten.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01YacWmjoxWSZRJC38XYxuZx

* proxy: carry aether1733, envoy --mode validate no longer segfaults on a QUIC listener

#1733's proxy workflow (run 41308410926, both arches) failed
//agent/test/envoy_validate:envoy_validate_test: `envoy --mode validate` of
node_bootstrap.json, edge_bootstrap.json and the ADS reconnect test's
bootstrap died with SIGSEGV in
Quic::ActiveQuicListenerFactory::initializeWorkerRouting().

envoyproxy/envoy#45504, in the 011e396 snapshot, moved the QUIC listener's
socket options there (behind envoy.restart_features.defer_worker_routing_init,
default true) and applies them to every worker's listen socket. Validation
mode creates no sockets (ValidationListenerComponentFactory::createListenSocket
returns nullptr), so *socket dereferences null. Upstream main still has it.
The proxy-supervisor's check before every hot restart on a changed bootstrap
is `envoy --mode validate`, so this would have blocked every bootstrap change
in production.

The patch skips a null socket, which only validation mode produces, as
validation did before #45504. Regression test: envoy_validate_test in the
proxy workflow, red on 8ce601a. Not reported upstream (on hold).

The "FilterStateMatcherValidationError.Key: value length must be at least 1
characters" line in the same log is TestAgentCaptureListenerAndTableValidate's
expected rejection ("refused as it must be"); that test passed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01YacWmjoxWSZRJC38XYxuZx

* proxy: aether1733's production exposure is a future static QUIC listener; refresh the extension count

- The aether1733 comment (MODULE.bazel, README) overstated the exposure: the
  chart's bootstraps carry static clusters only (listeners come over LDS), so
  the supervisor's pre-restart `--mode validate` does not crash today. A future
  bootstrap with a static QUIC listener would fail it, and every hot restart.
  The crash needs concurrency > 1 (the BPF reuseport option); raw-UDP
  listeners are unaffected.
- extensions_build_config.bzl: 354 upstream extensions - 35 dropped = 319 at
  011e396. The five new ones are named; tls.certificate_selectors.dynamic_modules
  is dropped by the existing pattern, and the four that compile in
  (priority_load_shed, host_allowlist, uri_template matcher,
  ai_protocol_manager in-memory buffer) are unused by aether and reach none of
  the wasm, dynamic-module or Rust machinery, so the policy keeps them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01YacWmjoxWSZRJC38XYxuZx

---------

Co-authored-by: Claude Opus 5.5 <[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.

2 participants