BUG/MINOR: peers: Don't wait for a remote resync if there no remote peer

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.
This commit is contained in:
Christopher Faulet 2024-04-25 21:47:01 +02:00
parent 0243691de1
commit 4b1a7ea66c

View 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 */