]> git.kaiwu.me - haproxy.git/commit
BUG/MEDIUM: cli: fix master CLI connection slot leak on client disconnect 20260430-mcli-serverfin
authorAlexander Stephan <alexander.stephan@sap.com>
Thu, 30 Apr 2026 14:23:52 +0000 (14:23 +0000)
committerWilliam Lallemand <wlallemand@haproxy.com>
Thu, 30 Apr 2026 14:54:55 +0000 (16:54 +0200)
commitf47d80402a0fefc16ffcda036db95c6d80ad9ed4
tree8bdb30d6edd2fcaba988e75b026c3141a41c9d36
parent66b00543c5d7b1024fd6dea8155350793676ec8e
BUG/MEDIUM: cli: fix master CLI connection slot leak on client disconnect

In master-worker mode the master CLI proxy (mworker_proxy) has a
hardcoded maxconn of 10. When a client connects to the master CLI
socket and issues a command that gets forwarded to an unresponsive
worker (e.g. one that is stuck or very slow), the connection hangs
waiting for the worker's response. If the client then disconnects
(timeout, Ctrl-C, etc.), the connection slot is never released because
the client-side FIN is never acknowledged by the unresponsive worker.

After 10 such leaked slots the master CLI socket becomes completely
unreachable, returning "Resource temporarily unavailable" to any new
connection attempt. In containerized deployments this means readiness
probes start failing and the pod gets restarted.

The fix adds a timeout server-fin of 1s to the mworker_proxy. When
the client disconnects while waiting for a worker response, this
timeout ensures the dangling backend connection is cleaned up after
1s, freeing the connection slot. This does not affect normal CLI
operations since the timeout only starts after the client has already
closed its side of the connection.

A regression test is included that blocks the worker CLI thread using
"debug dev delay" with nbthread 1, fills all 10 master CLI slots,
waits for client-side timeouts, then verifies a new connection still
succeeds.

This fixes GH issue #3351.

This should be backported to all stable branches.

Co-authored-by: Martin Strenge <github@trixer.net>
Co-authored-by: William Lallemand <wlallemand@haproxy.com>
reg-tests/mcli/mcli_master_socket_leak.vtc [new file with mode: 0644]
src/cli.c