]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: peers: Be sure to always refresh recconnect timer in sync task
authorChristopher Faulet <cfaulet@haproxy.com>
Mon, 16 Oct 2023 05:48:26 +0000 (07:48 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Thu, 19 Oct 2023 13:26:43 +0000 (15:26 +0200)
A sync task used to manage reconnect, sessions creation or shutdown and data
synchronization is responsible to refresh reconnect and heartbeat timers for
each remote peers and trigger applets wakeup. These timers are used to
refresh the sync task timeer itself. Thus it is important to take care to
always properly refresh them.

However, when there are some data to push, the reconnect timer is not
checked. It may be expired and not refreshed. In this case, an expired timer
may be used to the sync task, leading to a storm of wakeups. The sync task
is woken up in loop because its timer is in the past, waking up Peer applets
at each time.

To fix the issue, the peer's reconnect timer is now refresh to the default
reconnect timeout, if necessary, when there are some data to push.

This patch must be backported to all stable versions.

src/peers.c

index e116d53fd1f1ffe88f97a412386af2ce2ced3963..d48a059dedadbfc7700d86f147ca96d5a037c63d 100644 (file)
@@ -3423,6 +3423,9 @@ struct task *process_peer_sync(struct task * task, void *context, unsigned int s
                                                                ps->flags &= ~PEER_F_HEARTBEAT;
                                                                /* Re-schedule another one later. */
                                                                ps->heartbeat = tick_add(now_ms, MS_TO_TICKS(PEER_HEARTBEAT_TIMEOUT));
+                                                               /* Refresh reconnect if necessary */
+                                                               if (tick_is_expired(ps->reconnect, now_ms))
+                                                                       ps->reconnect = tick_add(now_ms, MS_TO_TICKS(PEER_RECONNECT_TIMEOUT));
                                                                /* We are going to send updates, let's ensure we will
                                                                 * come back to send heartbeat messages or to reconnect.
                                                                 */