]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MAJOR: leastconn: Protect tree_elt with the lbprm lock
authorOlivier Houchard <ohouchard@haproxy.com>
Tue, 3 Jun 2025 02:37:26 +0000 (02:37 +0000)
committerOlivier Houchard <cognet@Oliviers-MacBook-Pro.local>
Tue, 3 Jun 2025 02:42:47 +0000 (04:42 +0200)
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.

src/lb_fwlc.c

index 10ad147b5af2721277b98d0089b7c019abfda7a8..a082505e333c0afd5af2ec42a9936b97210874a4 100644 (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;