From: Willy Tarreau Date: Sat, 17 May 2025 08:28:50 +0000 (+0200) Subject: BUG/MAJOR: queue: properly keep count of the queue length X-Git-Tag: v3.2-dev17~29 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=099c1b244266c38d77b39c2fdbb36074b28c9735;p=thirdparty%2Fhaproxy.git BUG/MAJOR: queue: properly keep count of the queue length The queue length was moved to its own variable in commit 583303c48 ("MINOR: proxies/servers: Calculate queueslength and use it."), however a few places were missed in pendconn_unlink() and assign_server_and_queue() resulting in never decreasing counts on aborted streams. This was reproduced when injecting more connections than the total backend could stand in TCP mode and letting some of them time out in the queue. No backport is needed, this is only 3.2. --- diff --git a/src/backend.c b/src/backend.c index 5cfa26311..0c824e668 100644 --- a/src/backend.c +++ b/src/backend.c @@ -1141,6 +1141,12 @@ int assign_server_and_queue(struct stream *s) HA_SPIN_UNLOCK(QUEUE_LOCK, &p->queue->lock); _HA_ATOMIC_DEC(&p->queue->length); + + if (p->queue->sv) + _HA_ATOMIC_DEC(&p->queue->sv->queueslength); + else + _HA_ATOMIC_DEC(&p->queue->px->queueslength); + _HA_ATOMIC_INC(&p->queue->idx); _HA_ATOMIC_DEC(&s->be->totpend); diff --git a/src/queue.c b/src/queue.c index d5f737bf5..1f9f6d8ab 100644 --- a/src/queue.c +++ b/src/queue.c @@ -197,10 +197,14 @@ void pendconn_unlink(struct pendconn *p) if (done) { oldidx -= p->queue_idx; - if (sv) + if (sv) { p->strm->logs.srv_queue_pos += oldidx; - else + _HA_ATOMIC_DEC(&sv->queueslength); + } + else { p->strm->logs.prx_queue_pos += oldidx; + _HA_ATOMIC_DEC(&px->queueslength); + } _HA_ATOMIC_DEC(&q->length); _HA_ATOMIC_DEC(&px->totpend);