]> git.kaiwu.me - haproxy.git/commitdiff
BUG/MEDIUM: peers: keep the earliest sync task deadline
authorFrederic Lecaille <flecaille@haproxy.com>
Fri, 16 Oct 2026 08:12:29 +0000 (10:12 +0200)
committerFrederic Lecaille <flecaille@haproxy.com>
Fri, 16 Oct 2026 08:41:24 +0000 (10:41 +0200)
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

index 4c89cad7bd4fd3e19c22710747b2e585a7c4a114..d9de05fbb4cb160f15cdffe3cbd211598956d098 100644 (file)
@@ -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 */