]> git.ipfire.org Git - thirdparty/haproxy.git/commit
BUG/MINOR: server: fix add server with consistent hash balancing master quic-interop flx04/master
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Fri, 12 Jun 2026 08:54:42 +0000 (10:54 +0200)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Fri, 12 Jun 2026 13:31:41 +0000 (15:31 +0200)
commit2ff861747cd745f2698e3e74c7f10b64a656be0c
tree2eefe7c8385997b304f2db8de22a547f636e77f5
parent98b1fd4ff9a719f34131fa04cbd93f92c0c362f7
BUG/MINOR: server: fix add server with consistent hash balancing

When a dynamic server is added with consistent hash balancing on the
backend, its lb_nodes elements are allocated and associated with a
calculated server key. This operation is performed in add server handler
via srv_alloc_lb(). By default, the server key is based on its ID.
However, automatic server ID is calculated later in add server handler,
which means the initial lb_nodes are not valid.

This could cause load balacing issue but in fact this is not directly
visible as the server key is recalculated when the dynamic server is
enabled via chash_queue_dequeue_srv() : all server lb_nodes are dequeued
and requeued with the now proper key.

Thus, "add server" handler must be corrected as it is buggy when
considering it alone. The simplest solution of the current patch is to
initialize server ID before srv_alloc_lb() is invoked. There is no issue
as handler runs under thread isolation so there is no risk of multiple
servers manipulating the same ID. Server insertion in proxy ID tree is
still performed at the end of the handler when all fallible operation
are completed.

The fact that server key is recalculated when the server is set to ready
state is a side effect of the following patch which was introduced in
3.0. What this means though is that users of older releases are facing a
bigger issue, with load-balancing not working as expected. Thus,
this patch is even more crucial for 2.8 and older releases.

  faa8c3e024b1e4e5833a8deaa6545675036544c6
  MEDIUM: lb-chash: Deterministic node hashes based on server address

This should fix github issue #3413. Thanks to Joao Morais for is
analysis on the problem.

This must be backported to all stable releases.
src/server.c