From: Hyeonggeun Oh Date: Mon, 30 Nov 2026 16:31:20 +0000 (+0000) Subject: BUG/MEDIUM: peers: do not clear the alive flag of a replacement session X-Git-Url: https://git.kaiwu.me/web/%7B@url%7D?a=commitdiff_plain;h=59ed0a5fd1d5d0dbc643827415c397e5021cef30;p=haproxy.git BUG/MEDIUM: peers: do not clear the alive flag of a replacement session When an incoming connection supersedes an established session with the same peer, the old applet is shut down with peer_session_forceshutdown(), then the new one is installed and the peer is flagged PEER_F_ALIVE. But when the old applet is released later, peer_session_release() clears PEER_F_ALIVE unconditionally, even though the applet does not own the peer anymore. The collision delay before the next liveness check is 50 to 2049ms while the first heartbeat is due after 3s, so the sync task finds the replacement not alive and kills it. The liveness is tracked per session, so clear the flag in __peer_session_deinit(), which is only called for the applet owning the peer, instead of on every applet release. In the collision path, the deinit happens before the new session is flagged, so the order is preserved. This should fix GH issue #3519. It must be backported to all stable versions. Signed-off-by: Hyeonggeun Oh --- diff --git a/src/peers.c b/src/peers.c index d242582e8..b8a6c6885 100644 --- a/src/peers.c +++ b/src/peers.c @@ -1159,8 +1159,8 @@ void __peer_session_deinit(struct peer *peer) st->remote_data = 0; } - /* reset teaching flags to 0 */ - peer->flags &= ~PEER_TEACH_FLAGS; + /* reset teaching and alive flags */ + peer->flags &= ~(PEER_TEACH_FLAGS|PEER_F_ALIVE); /* Mark the peer as stopping and wait for the sync task */ peer->flags |= PEER_F_WAIT_SYNCTASK_ACK; @@ -1234,7 +1234,6 @@ static void peer_session_release(struct appctx *appctx) HA_SPIN_LOCK(PEER_LOCK, &peer->lock); if (peer->appctx == appctx) __peer_session_deinit(peer); - peer->flags &= ~PEER_F_ALIVE; HA_SPIN_UNLOCK(PEER_LOCK, &peer->lock); TRACE_STATE("peer session released", PEERS_EV_SESS_END, appctx, peer); }