]> git.kaiwu.me - haproxy.git/commit
BUG/MEDIUM: peers: don't push updates before a reloaded process resyncs
authorFrederic Lecaille <flecaille@haproxy.com>
Tue, 1 Dec 2026 14:16:33 +0000 (15:16 +0100)
committerFrederic Lecaille <flecaille@haproxy.com>
Tue, 1 Dec 2026 14:44:56 +0000 (15:44 +0100)
commit3085933cd7ad27bcb23f815d463145f386f4129c
treec4a7b2fe19631811e8fedf0e3ceca82f44d70833
parent6e55119c13f6cfd4d73f8a0e3ade8aa8b7ccdafb
BUG/MEDIUM: peers: don't push updates before a reloaded process resyncs

On a soft reload, the new process starts with empty stick-tables and
serves immediately. As soon as its sessions to the remote peers are up,
peer_send_msgs() pushes its own values to them: it only checks the learn
state of the destination peer, never the resync state of the process
itself. The remote peers overwrite their entries with those values, then
count them and push them back, possibly after the old process's lesson
has arrived. Since updates carry absolute values and no ordering, the key
then continues from the value counted from scratch on every peer, and its
whole history is lost.

The same race is visible before the local lesson is even assigned: the
first push to a remote peer happens as soon as that session is up, which
is what makes the reset possible when both nodes write the same key.

Fix this by not pushing anything while the process has not finished its
resync (PEERS_RESYNC_FINISHED). Updates made meanwhile are not lost:
they are sent with their current value once the resync is over, which is
correct since a message carries a value and not an increment.

This is restricted to a process started from older ones, which is what
nb_oldpids accounts for: it is non-zero only when -sf or -st was used and
the signal could be delivered to the old processes. An instance started
on its own has no older process to learn from, and holding its pushes
back delays the replication of its entries by up to PEER_RESYNC_TIMEOUT
(5s): with no ancestor and two peers starting empty, neither can teach
the other, so the remote resync state is only left on timeout. This is
not theoretical: with the condition applied unconditionally, both
reg-tests/stickiness/{srvkey-addr,lb-services}.vtc fail. They start two
instances without ancestors, one side reports used:0, and the requests
routed there get a 504 or time out. Both pass with the nb_oldpids
restriction, which only affects processes that really are reloaded.

The condition was introduced with the peers code itself, so it should be
backported to all stable versions.

This fixes GitHub issue #3613. Thank you to @swenske for the detailed
report, the traces and the analysis of the race.
src/peers.c