Skip to content

Commit 099c1b2

Browse files
committed
BUG/MAJOR: queue: properly keep count of the queue length
The queue length was moved to its own variable in commit 583303c ("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.
1 parent 6be02d1 commit 099c1b2

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/backend.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1141,6 +1141,12 @@ int assign_server_and_queue(struct stream *s)
11411141
HA_SPIN_UNLOCK(QUEUE_LOCK, &p->queue->lock);
11421142

11431143
_HA_ATOMIC_DEC(&p->queue->length);
1144+
1145+
if (p->queue->sv)
1146+
_HA_ATOMIC_DEC(&p->queue->sv->queueslength);
1147+
else
1148+
_HA_ATOMIC_DEC(&p->queue->px->queueslength);
1149+
11441150
_HA_ATOMIC_INC(&p->queue->idx);
11451151
_HA_ATOMIC_DEC(&s->be->totpend);
11461152

src/queue.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,10 +197,14 @@ void pendconn_unlink(struct pendconn *p)
197197

198198
if (done) {
199199
oldidx -= p->queue_idx;
200-
if (sv)
200+
if (sv) {
201201
p->strm->logs.srv_queue_pos += oldidx;
202-
else
202+
_HA_ATOMIC_DEC(&sv->queueslength);
203+
}
204+
else {
203205
p->strm->logs.prx_queue_pos += oldidx;
206+
_HA_ATOMIC_DEC(&px->queueslength);
207+
}
204208

205209
_HA_ATOMIC_DEC(&q->length);
206210
_HA_ATOMIC_DEC(&px->totpend);

0 commit comments

Comments
 (0)