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.
This commit is contained in:
Willy Tarreau 2025-05-17 10:28:50 +02:00
parent 6be02d1c6e
commit 099c1b2442
2 changed files with 12 additions and 2 deletions

View File

@ -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);

View File

@ -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);