Skip to content

fix(mux): close a pooled connection to a removed backend once it is idle - #1765

Merged
FlorentinDUBOIS merged 2 commits into
mainfrom
fix/mux-retired-backend-cleanup
Oct 1, 2026
Merged

FlorentinDUBOIS merged 2 commits into
mainfrom
fix/mux-retired-backend-cleanup

Conversation

@FlorentinDUBOIS

@FlorentinDUBOIS FlorentinDUBOIS commented Oct 1, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #1760

What changes

  • Close idle retired connections. Since fix(mux): never reuse a pooled connection to a removed backend #1743 a pooled backend connection whose backend left the configuration is not reused, but it stayed open until the frontend session ended, so the removed backend never went from Closing to Closed. Mux::ready_inner now drops such a connection once it carries no stream (H1 keep-alive, or H2 with an empty stream table) through Connection::force_disconnect; the dead-backend sweep closes it and releases its connection on the backend. A connection already idle at removal time is closed on its session's next event. RemovedBackendHasNoConnections is unchanged: it fires when the last Rc of the backend drops, which the session's BackendRegistry holds until the session closes.
  • Reload side effect, documented. A reload changing a backend's weight, sticky_id or backup is applied as RemoveBackend then AddBackend (ConfigState::diff), so live sessions now drop their pooled connection to that backend and dial it again. CHANGELOG and lib/src/protocol/mux/LIFECYCLE.md.

Tests

Validation

  • cargo +nightly fmt --all --check
  • cargo +1.93.1 clippy --all-features --all-targets --locked -- -D warnings
  • RUSTDOCFLAGS="-D warnings" cargo doc --all-features --no-deps
  • cargo test -p sozu-lib --all-features
  • cargo test -p sozu-e2e --locked --features opentelemetry,splice,simd -- remove_cluster_tests mux_tests keep_alive
  • cargo +nightly fuzz build
  • check_doc_citations.py in its four modes

@FlorentinDUBOIS
FlorentinDUBOIS force-pushed the fix/mux-retired-backend-cleanup branch from 21b1f7e to d14e332 Compare October 1, 2026 18:58
A pooled backend connection whose backend left the configuration is no
longer reused (#1735), but it stayed open until its frontend session
ended, so the removed backend kept a connection and never went from
Closing to Closed.

Mux::ready_inner now drops such a connection as soon as it carries no
stream: an H1 keep-alive, or an H2 connection with an empty stream
table. Connection::force_disconnect raises HUP and the dead-backend
sweep closes it on the next iteration, releasing its connection on the
backend.

A reload that changes a backend's weight, sticky_id or backup is
applied as RemoveBackend then AddBackend (ConfigState::diff), so live
sessions now drop their pooled connection to it and dial it again;
documented in CHANGELOG and LIFECYCLE.md.

Adds router unit tests for the retired-backend reuse skip in its three
arms, and an e2e test for RemoveBackend within a surviving cluster.

Fixes #1760

Signed-off-by: Florentin Dubois <[email protected]>
@FlorentinDUBOIS
FlorentinDUBOIS force-pushed the fix/mux-retired-backend-cleanup branch from d14e332 to 045f932 Compare October 1, 2026 20:39
@FlorentinDUBOIS
FlorentinDUBOIS merged commit 36eca96 into main Oct 1, 2026
23 checks passed
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.

fix(mux): close a pooled connection to a removed backend once it is idle

1 participant