From f9a7c442f64263476210756e375ff923d7f6cf33 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Wed, 9 Jun 2021 15:56:16 +0200 Subject: [PATCH] MINOR: backend: only skip LB when there are actual connections In 2.3, a significant improvement was brought against situations where the queue was heavily used, because some LB algos were still checked for no reason before deciding to put the request into the queue. This was commit 82cd5c13a ("OPTIM: backend: skip LB when we know the backend is full"). As seen in previous commit ("BUG/MAJOR: queue: set SF_ASSIGNED when setting strm->target on dequeue") the dequeuing code is extremely tricky, and the optimization above tends to emphasize transient issues by making them permanent until the next reload, which is not acceptable as the code must always be robust against any bad situation. This commit brings a protection against such a situation by slightly relaxing the test. Instead of checking that there are pending connections in the backend queue, it also verifies that the backend's connections are not solely composed of queued connections, which would then indicate we are in this situation. This is not rocket science, but at least if the situation happens, we know that it will unlock by itself once the streams have left, as new requests will be allowed to reach the servers and to flush the queue again. This needs to be backported to 2.4 and 2.3. --- src/backend.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backend.c b/src/backend.c index 65beb84b7..6494912af 100644 --- a/src/backend.c +++ b/src/backend.c @@ -651,7 +651,7 @@ int assign_server(struct stream *s) /* if there's some queue on the backend, with certain algos we * know it's because all servers are full. */ - if (s->be->nbpend && + if (s->be->nbpend && s->be->nbpend != s->be->beconn && (((s->be->lbprm.algo & (BE_LB_KIND|BE_LB_NEED|BE_LB_PARM)) == BE_LB_ALGO_FAS)|| // first ((s->be->lbprm.algo & (BE_LB_KIND|BE_LB_NEED|BE_LB_PARM)) == BE_LB_ALGO_RR) || // roundrobin ((s->be->lbprm.algo & (BE_LB_KIND|BE_LB_NEED|BE_LB_PARM)) == BE_LB_ALGO_SRR))) { // static-rr