BUG/MAJOR: leastconn: Protect tree_elt with the lbprm lock

In fwlc_srv_reposition(), set the server's tree_elt while we still hold
the lbprm read lock. While it was protected from concurrent
fwlc_srv_reposition() calls by the server's lb_lock, it was not from
dequeuing/requeuing that could occur if the server gets down/up or its
weight is changed, and that would lead to inconsistencies, and the
watchdog killing the process because it is stuck in an infinite loop in
fwlc_get_next_server().

This hopefully fixes github issue #2990.

This should be backported to 3.2.
This commit is contained in:
Olivier Houchard 2025-06-03 02:37:26 +00:00 committed by Olivier Houchard
parent 368d01361a
commit 913b2d6c83

View File

@ -496,10 +496,10 @@ static void fwlc_srv_reposition(struct server *s)
*/
mt_list_unlock_full(&s->lb_mt_list, list);
HA_RWLOCK_RDUNLOCK(LBPRM_LOCK, &s->proxy->lbprm.lock);
s->tree_elt = tree_elt;
HA_RWLOCK_RDUNLOCK(LBPRM_LOCK, &s->proxy->lbprm.lock);
if (allocated_elt)
s->free_elt = allocated_elt;