BUG/MEDIUM: lb-leastconn: Reposition a server using the right eweight
authorChristopher Faulet <cfaulet@haproxy.com>
Fri, 11 Dec 2020 14:36:01 +0000 (15:36 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Mon, 14 Dec 2020 10:50:31 +0000 (11:50 +0100)
commitfd0d6681600b1d1dbbfc8db04bb032bc78e33243
tree6ed0c88ace058728d379c1f0a791182bf2d9a0aa
parentfd188ab5dbed4c626c5c877e212ad922108f1346
BUG/MEDIUM: lb-leastconn: Reposition a server using the right eweight

Depending on the context, the current eweight or the next one must be used
to reposition a server in the tree. When the server state is updated, for
instance its weight, the next eweight must be used because it is not yet
committed. However, when the server is used, on normal conditions, the
current eweight must be used.

In fact, it is only a bug on the 1.8. On newer versions, the changes on a
server are performed synchronously. But it is safer to rely on the right
eweight value to avoid any futur bugs.

On the 1.8, it is important to do so, because the server state is updated
and committed inside the rendez-vous point. Thus, the next server state may
be unsync with the current state for a short time, waiting all threads join
the rendez-vous point. It is especially a problem if the next eweight is set
to 0. Because otherwise, it must not be used to reposition the server in the
tree, leading to a divide by 0.

This patch must be backported as far as 1.8.

(cherry picked from commit cb33d3ac7f8dbc3f7323606a521d29dc100adbda)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 0881842bf7a8de3e3cf93bece19f160945ba984a)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 8498c5fe48b36371f2bf8e12217d57b76adde561)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
src/lb_fwlc.c