Repository navigation
fix(udp): key flows on the client source address, not on the affinity key - #1746
Merged
Merged
Conversation
FlorentinDUBOIS
force-pushed
the
fix/udp-flow-key-and-idle-expiry
branch
from
October 1, 2026 11:26
b49cf29 to
aae7c0e
Compare
This was referenced Oct 1, 2026
FlorentinDUBOIS
force-pushed
the
fix/udp-flow-key-and-idle-expiry
branch
from
October 1, 2026 17:02
971f65e to
b34d83c
Compare
… key Under the default affinity_key = SOURCE_IP, FlowKey::from_src zeroed the source port, so every socket of one client IP shared one flow and one connected upstream socket, and every backend reply went to the port of the socket that opened the flow. The flow table is now keyed on the client source IP and port whatever the affinity key, as the #1273 design states; the affinity key only feeds the backend-selection hash, so the sockets of one IP still land on one backend under HRW / MAGLEV. FlowKey::from_src loses its with_port argument, UdpManager::affinity_with_port and the shell's client_key normalisation are removed. Also add the end-to-end idle-eviction test the lost-wakeup fix (596b3ec) lacked: a flow silent past its idle timeout is torn down and the next datagram opens a new one. Fixes #1732 Signed-off-by: Florentin Dubois <[email protected]>
…y as the hash input The CHANGELOG entry carries the BREAKING (library API) marker: FlowKey::from_src lost its bool and UdpManager::affinity_with_port() was removed, both public in sozu-lib 2.2.1. fuzz/README.md states the new invariant (the flow key keeps the port), and the HRW / Maglev / sharding docs and comments name the UDP affinity key, not the flow key, as the hash input. test_udp_idle_flow_is_torn_down now asserts eviction on the fresh PPv2 header alone, required on both datagrams, and only logs the upstream port, which the kernel may legitimately reuse. Signed-off-by: Florentin Dubois <[email protected]>
… there are Thirty-three flows (two alternating sockets, thirty one-datagram sockets and one that speaks again later) under the default cluster knobs, max_flows = 0 and a 2 s listener idle timeout: once all are silent past the timeout, no connected upstream socket to any backend may remain, and the returning socket gets a new flow on a new upstream socket. On 2.2.1 (with SOURCE_IP_PORT, so its flows are per socket) this keeps all 33 upstream sockets past the timeout on some runs; adding 596b3ec's armed_deadline reset alone makes it pass, as does origin/main. doc/configure.md states that the listener front_timeout / back_timeout are the only UDP idle timeout and which datagram refreshes which. Signed-off-by: Florentin Dubois <[email protected]>
test_udp_every_idle_flow_is_torn_down opened its 31 new flows one round trip after another with a 2 s idle timeout. On a loaded runner that took longer than the timeout, so the first flows were reaped, as they should be, before the count of live upstream sockets, which then read 32 instead of 33. The new flows are now opened in one burst and their replies collected afterwards, so all 33 are live when they are counted. The assertions are unchanged. Signed-off-by: Florentin Dubois <[email protected]>
FlorentinDUBOIS
force-pushed
the
fix/udp-flow-key-and-idle-expiry
branch
from
October 1, 2026 18:33
b34d83c to
8acba7c
Compare
Signed-off-by: Florentin Dubois <[email protected]>
FlorentinDUBOIS
added a commit
that referenced
this pull request
Oct 3, 2026
…1809) Audit of the docs, `bin/config.toml` and `os-build/config.toml` against everything merged on `main` from 2026-10-01 to 2026-10-03 (43 commits, #1724 through #1808). Most of the new keys were already documented by their own PRs (`max_connection_attempts`, `h2_stream_refusal_percent`, health check `mode`/`accepted_statuses`, the raised flood defaults, the 16 MiB connection window). This PR fixes what was still stale. | Area | Where | Was | Now | |---|---|---|---| | #1806 | `bin/config.toml`, `os-build/config.toml` answer comments | 503 only for "no backend available"; "504 means the backend timed out" | 503 also when every attempt failed; 504 = connected backend silent or frontend timeout while waiting; connect timeout fails over | | #1806 | `bin/config.toml` `max_connection_attempts` | connect timeout always fails over | a TCP session whose connect times out is closed | | #1806 | `doc/debugging_strategies.md` | 503 after a circuit breaker of 3 failed connections; ERROR log lines, one that no longer exists | `max_connection_attempts` (default 5), `backend.connect.retries_exhausted`, real TCP log levels and text | | #1806 | `doc/configure.md` `front_timeout` / `connect_timeout` rows | "inactivity for a request to connect" | time to establish a backend connection; HTTP fails over, TCP closes; H1 failover bound by `front_timeout` | | #1806 | `doc/configure.md` `client_timeout_during_response`, `backend_timeout`, `http.503.errors` | "connection-level slowness", "circuit breaker" | failover case included; established connection only; attempt budget | | #1806 | `LIFECYCLE.md` backend timer | 504 for any linked stream | established connection only | | #1806 | `cli.rs` help, `doc/configure_cli.md` | "answered 503" | "or a TCP session is closed" | | #1756 | `doc/configure.md` flood metrics | RST lifetime rows described as absolute ceilings; no `window_update_stream0_window` row | floor-and-ratio semantics; row added | | #1756/#1798 | `doc/architecture.md`, `doc/h2_mux_internals.md` | 6 / 13 `H2FloodConfig` thresholds | 14, with `h2_stream_refusal_percent` | | #1756 | `doc/configure_admin_ops.md` | "halve" example 50/25 (old defaults); H2 knobs HTTPS only | 1000/500; HTTP and HTTPS; `h2.flood.stream_refused` | | #1752 | `doc/configure.md` glitch tuning | "1 MiB window ... about 64" frames | 64 KiB stream window, about four | | #1805 | `doc/health_checks.md` | `remove` resets backends to healthy; DOWN logs an error; `load_balancing.rs::BackendList::healthy` | backends keep their last state (see note); warning; `BackendList::select_tiers` in `backends.rs` | | #1805 | `doc/metrics.md` | health-check counters "per cluster" | unlabelled | | #1805 | `doc/configure_cli.md` | no health-check section | short section, `--mode`, `--probe-timeout` vs global `--timeout` | | #1746 | `cli.rs` `--load-balancing-policy`, `bin/config.toml`, proto comment | HRW/MAGLEV key = UDP flow key | UDP affinity key (source IP, or IP and port) | | UDP | `doc/configure.md` | hot upgrade drains flows bounded by idle timeout; `udp.flows.evicted` reasons | soft-stop closes flows at once; listener removal/soft-stop/abort added | | #1770 | `doc/udp_simulation.md` | no per-source limits | in reconfig storms and the invariant list | | #1743 | `doc/lifetime_of_a_session.md` | keep-alive backend always reused | unless its backend was removed | | older | `command.proto` update messages | `h2_stream_shrink_ratio >= 1` | `>= 2`, as validated in `state.rs` | | #1806 | e2e shuffle-sharding doc comment | "three connection attempts" | `max_connection_attempts` (5 by default) | Reported here, not changed in this PR: - `sozu cluster health-check remove` does not reset backends a probe marked DOWN (`remove_health_check_state` skips the reset that `set_health_check_config(None)` does), so they stay out of rotation until the cluster is added again. The doc now describes this. It looks like a code bug. - `sozu top`'s H2 pane reads `h2.flood.violation.{rapid_reset,made_you_reset,ping,settings,priority,continuation}`, which the detector never emits (it emits `rst_stream_pre_response_lifetime`, `ping_window`, ...). Only `glitch_window` matches, and `h2.flood.stream_refused` is not shown. - `h2_flood_detector.rs` comments still refer to a 1 MiB connection window, and the `h2_stream_idle_timeout_seconds` proto comment says "Default: 30" where the value inherits `back_timeout`. - `connections.rejected_per_cluster_ip` is documented as also counting TCP rejections; only the HTTP 429 path increments it. Validation: - `sozu config check` passes on `bin/config.toml`, on a copy with every commented key under review uncommented (global and cluster `max_connection_attempts`, the H2 block, the health check block), and on `os-build/config.toml` with local state/socket paths. Negative controls (`max_connection_attempts = 0`; `expected_status = 200` next to `accepted_statuses`) are rejected. - `cargo +1.93.1 test -p sozu-command-lib --all-features --locked`: 235 passed. - `cargo +1.93.1 test -p sozu --bin sozu --locked`: 124 passed (including the `--load-balancing-policy` help tests). - `cargo +nightly fmt --all --check` and `python3 .github/scripts/check_doc_citations.py --root . --base origin/main` are clean. Signed-off-by: Florentin Dubois <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
UDP flows were keyed on the affinity key: under the default
affinity_key = SOURCE_IP,FlowKey::from_srczeroed the source port, so every socket of one client IP shared one flow and one connected upstream socket, and backend replies went to the port of the socket that opened the flow.The flow table is now keyed on the client source IP and port whatever the affinity key, as the #1273 design states (virtual 4-tuple flows, one connected upstream socket per flow).
affinity_keyonly feeds the backend-selection hash, so the sockets of one IP still land on one backend under HRW / Maglev.FlowKey::from_srcloses itswith_portargument;UdpManager::affinity_with_portand the shell's port normalisation are removed.max_flowsslot.main: it matches the lost timer wakeup fixed in 596b3ec, which is not in a release yet. This adds the end-to-end idle-eviction test that fix lacked.doc/configure.md,LIFECYCLE.md, proto comment) and CHANGELOG updated.Tests:
same_ip_clients_get_distinct_flows_and_their_own_replies(unit),test_udp_same_ip_clients_are_distinct_flowsandtest_udp_idle_flow_is_torn_down(e2e).Fixes #1732