]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: peers: Don't wait for a remote resync if there no remote peer
authorChristopher Faulet <cfaulet@haproxy.com>
Thu, 25 Apr 2024 19:47:01 +0000 (21:47 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Thu, 25 Apr 2024 19:47:02 +0000 (21:47 +0200)
When a resync is needed, a local resync is first tried and if it does not
work, a remote resync is tried. It happens when the worker is started for
instance. There is a timeout to wait for the local resync, except for the
first start. And if the local resync fails or times out, the same timeout
is applied to the remote resync. This one is always applied, even if there
is no remote peer.

On the other hand, on reload, if the old worker has never performed its
resync, it does not try to resync the new worker. And here there is an
issue. On the first reload, when there is no remote peer, we must wait for
the resync timeout expiration to have a chance to resync the new worker. If
the reload happens too early, there is no resync at all. Concretly, after a
fresh start, if a reload happens in the first 5 seconds, there is no resync
with the new worker. The issue only concerns the first reload and affects
the second worker.

To fix the issue, we must only skip the remote resync if there is no remote
peer. This way, on a fresh start, the worker is immediately considered as
resync. The local reynsc is skipped because it is the first worker and the
remote resync is skipped because there is no remote peer.

This patch must be backported to all stable versions.

src/peers.c

index 88bfc0dd193324a6793fc2d4a2c2a3c44af3d42b..db85acf727b3f1825c967fb748bd503cc522823d 100644 (file)
@@ -3535,10 +3535,10 @@ static void __process_running_peer_sync(struct task *task, struct peers *peers,
                HA_SPIN_UNLOCK(PEER_LOCK, &peer->lock);
        } /* for */
 
-       /* Resync from remotes expired: consider resync is finished */
+       /* Resync from remotes expired or no remote peer: consider resync is finished */
        if (((peers->flags & PEERS_RESYNC_STATEMASK) == PEERS_RESYNC_FROMREMOTE) &&
            !(peers->flags & PEERS_F_RESYNC_ASSIGN) &&
-           tick_is_expired(peers->resync_timeout, now_ms)) {
+           (tick_is_expired(peers->resync_timeout, now_ms) || !peers->remote->next)) {
                /* Resync from remote peer needed
                 * no peer was assigned for the lesson
                 * and resync timeout expire */