From 80b286a064eaec828b7fd10e98e3f945e8b244f3 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Sun, 30 Nov 2008 21:51:58 +0100 Subject: [PATCH] [BUG] do not dequeue requests on a dead server Kai Krueger reported a problem when a server goes down with active connections. A lot of connections were drained by that server. Kai did an amazing job at tracking this bug down to the dequeuing mechanism which forgets to check the server state before allowing a request to be sent to a server. The problem occurs more often with long requests, which have a chance to complete after the server is completely marked down, and to find requests in the global queue which have not yet been fetched by other servers. The fix consists in ensuring that a server is up before sending it any new request from the queue. --- include/proto/queue.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/include/proto/queue.h b/include/proto/queue.h index 6899aee48..be78b5356 100644 --- a/include/proto/queue.h +++ b/include/proto/queue.h @@ -64,10 +64,11 @@ static inline struct pendconn *pendconn_from_px(const struct proxy *px) { } /* returns 0 if nothing has to be done for server regarding queued connections, - * and non-zero otherwise. Suited for and if/else usage. + * and non-zero otherwise. If the server is down, we always return zero. Suited for + * and if/else usage. */ static inline int may_dequeue_tasks(const struct server *s, const struct proxy *p) { - return (s && (s->nbpend || p->nbpend) && + return (s && (s->state & SRV_RUNNING) && (s->nbpend || p->nbpend) && (!s->maxconn || s->cur_sess < srv_dynamic_maxconn(s))); }