From: Olivier Houchard Date: Tue, 1 Dec 2026 10:15:30 +0000 (+0100) Subject: BUG/MEDIUM: leastconn: don't hide an avoided server from later lookups X-Git-Url: https://git.kaiwu.me/web/%7B@url%7D?a=commitdiff_plain;h=496632ac001a4a70931613b98d58e0772070849a;p=haproxy.git BUG/MEDIUM: leastconn: don't hide an avoided server from later lookups When fwlc_get_next_server() walks past a node without picking a server from it, it raises the smallest key recorded in lbprm.lb_seq so that the next lookups start further. It also does so after skipping the server to avoid on a redispatch, though this server remains usable for everybody else. The server then stays out of the lookups until another one is queued at a key at or below its own: it gets no traffic while being the least loaded, and if the other servers leave, requests are queued and end with a 503 while a server is up. Fix it by no longer raising the smallest key once a server was avoided in the lookup. It can be reproduced with two servers, "retry-on 503" and "option redispatch": hold a few requests on one server and have the other one return a 503, the next requests all go to the busy server. This was introduced by commit 9fe72bba3 ("MAJOR: leastconn; Revamp the way servers are ordered.") in 3.2-dev9. This must be backported as far as 3.2. --- diff --git a/src/lb_fwlc.c b/src/lb_fwlc.c index e340fbaa7..ee876e21f 100644 --- a/src/lb_fwlc.c +++ b/src/lb_fwlc.c @@ -848,7 +848,7 @@ redo: * If we have a bigger element than the smallest recorded, and we're up to date, * update the smallest one. */ - if (likely(newcurseq == curseq && FWLC_LBPRM_SMALLEST(newcurseq) < node->key)) { + if (likely(!avoided && newcurseq == curseq && FWLC_LBPRM_SMALLEST(newcurseq) < node->key)) { if (fwlc_set_seq_and_smallest(&p->lbprm, curseq, FWLC_LBPRM_SEQ(curseq), node->key) != 0) { curseq = FWLC_LBPRM_SEQ(curseq) | ((uint64_t)node->key << 32); __ha_barrier_store();