BUG/MEDIUM: peers: also limit the number of incoming updates
authorWilly Tarreau <w@1wt.eu>
Thu, 15 May 2025 13:41:50 +0000 (15:41 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Mon, 2 Jun 2025 15:31:32 +0000 (17:31 +0200)
commitc72839b0020128393c4d3c67fa4eb5355d2f4c9f
tree06b6521bcdfe83caf2554782f673614d94c8e18f
parent9e587df0b88b661379e10f2121825e22843d1033
BUG/MEDIUM: peers: also limit the number of incoming updates

There's a configurable limit to the number of messages sent to a
peer (tune.peers.max-updates-at-once), but this one is not applied to
the receive side. While it can usually be OK with default settings,
setups involving a large tune.bufsize (1MB and above) regularly
experience high latencies and even watchdogs during reloads because
the full learning process sends a lot of data that manages to fill
the entire buffer, and due to the compactness of the protocol, 1MB
of buffer can contain more than 100k updates, meaning taking locks
etc during this time, which is not workable.

Let's make sure the receiving side also respects the max-updates-at-once
setting. For this it counts incoming updates, and refrains from
continuing once the limit is reached. It's a bit tricky to do because
after receiving updates we still have to send ours (and possibly some
ACKs) so we cannot just leave the loop.

This issue was reported on 3.1 but it should progressively be backported
to all versions having the max-updates-at-once option available.

(cherry picked from commit b26f3fe54e0ca5d54cc4fbcd771bfefbe728991c)
Signed-off-by: Willy Tarreau <w@1wt.eu>
(cherry picked from commit 8dfea165a389c44466d58fea9827c51017977d5a)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
src/peers.c