From 5e3037e64ec22ca9e9bd8bbbd5591aeaf72a56aa Mon Sep 17 00:00:00 2001 From: Frederic Lecaille Date: Fri, 16 Oct 2026 10:12:29 +0200 Subject: [PATCH] BUG/MEDIUM: peers: keep the earliest sync task deadline When a peer reconnects, heartbeats to another idle peer may be delayed. The remote peer may then close the connection due to inactivity. All peers in a section share one sync task. While processing each peer, the task's deadline is overwritten, even when an earlier peer needs to wake up sooner. Keep the earliest deadline across all peers, both when updates are pending and when peers are idle. The faulty assignments were introduced by commit 045e0d4b3 ("BUG/MINOR: peers: Really close the sessions with no heartbeat.") during 2.0 development. Thank you to @snh for having reported this issue in GH #3536. This fix should be backported to all maintained stable branches. --- src/peers.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/peers.c b/src/peers.c index 4c89cad7b..d9de05fbb 100644 --- a/src/peers.c +++ b/src/peers.c @@ -3724,7 +3724,7 @@ static void __process_running_peer_sync(struct task *task, struct peers *peers, * come back to send heartbeat messages or to reconnect. */ TRACE_DEVEL("wakeup peer session to send update", PEERS_EV_SESS_WAKE, NULL, peer); - task->expire = tick_first(peer->reconnect, peer->heartbeat); + task->expire = tick_first(task->expire, tick_first(peer->reconnect, peer->heartbeat)); appctx_wakeup(peer->appctx); break; } @@ -3757,7 +3757,7 @@ static void __process_running_peer_sync(struct task *task, struct peers *peers, TRACE_DEVEL("wakeup peer session to send heartbeat message", PEERS_EV_SESS_WAKE, NULL, peer); appctx_wakeup(peer->appctx); } - task->expire = tick_first(peer->reconnect, peer->heartbeat); + task->expire = tick_first(task->expire, tick_first(peer->reconnect, peer->heartbeat)); } } /* else do nothing */ -- 2.47.3