]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: peers: Don't start resync on reload if local peer is not up-to-date
authorChristopher Faulet <cfaulet@haproxy.com>
Fri, 26 Aug 2022 16:46:16 +0000 (18:46 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Mon, 29 Aug 2022 09:38:02 +0000 (11:38 +0200)
On a reload, if the previous resync was not finished, the freshly old worker
must not try to start a new resync. Otherwise, it will compete with the
older wokers, slowing down or blocking the resync. Only an up-to-date woker
must try to perform a local resync.

This patch must be backported as far as 2.0 (and maybe to 1.8 too).

src/peers.c

index 39a5382d3512d347a1a2cc7e90448af62a6f3513..d4aa69f232eacb408549e7f93aa090306a41a50e 100644 (file)
@@ -3472,12 +3472,14 @@ struct task *process_peer_sync(struct task * task, void *context, unsigned int s
                                peers->resync_timeout = tick_add(now_ms, MS_TO_TICKS(PEER_RESYNC_TIMEOUT));
 
                        /* If there's no active peer connection */
-                       if (!tick_is_expired(peers->resync_timeout, now_ms) &&
+                       if ((peers->flags & PEERS_RESYNC_STATEMASK) == PEERS_RESYNC_FINISHED &&
+                           !tick_is_expired(peers->resync_timeout, now_ms) &&
                            (ps->statuscode == 0 ||
                             ps->statuscode == PEER_SESS_SC_SUCCESSCODE ||
                             ps->statuscode == PEER_SESS_SC_CONNECTEDCODE ||
                             ps->statuscode == PEER_SESS_SC_TRYAGAIN)) {
-                               /* The resync timeout is not expired and
+                               /* The resync is finished for the local peer and
+                                *   the resync timeout is not expired and
                                 *   connection never tried
                                 *   or previous peer connection was successfully established
                                 *   or previous tcp connect succeeded but init state incomplete