MINOR: backend: only skip LB when there are actual connections
authorWilly Tarreau <w@1wt.eu>
Wed, 9 Jun 2021 13:56:16 +0000 (15:56 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 16 Jun 2021 07:05:35 +0000 (09:05 +0200)
commitf9a7c442f64263476210756e375ff923d7f6cf33
treea843e405c613ce2549ed0429ad06a354f58000e3
parent7867cebf31403b6d7bab97cb3047e6d77238fcdc
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