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.
* 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();