From 1385e33eb089093dbc970dbc2759d2969ae533c5 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Fri, 27 Sep 2024 18:54:07 +0200 Subject: [PATCH] BUG/MINOR: queue: make sure that maintenance redispatches server queue Turning a server to maintenance currently doesn't redispatch the server queue unless there's an explicit "option redispatch" and no "option persist", while the former has never really been the purpose of this test. Better refine this so that forced maintenance also causes the queue to be flushed, and possibly redispatched unless the proxy has option persist. This way now when turning a server to maintenance, the queue is immediately flushed and streams can decide what to do. This can be backported, though there's no need to go far since it was never directly reported and only noticed as part of debugging some rare "shutdown sessions" strangeness, which it might participate to. --- src/queue.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/queue.c b/src/queue.c index a1bc46c57..195881de1 100644 --- a/src/queue.c +++ b/src/queue.c @@ -498,8 +498,10 @@ int pendconn_redistribute(struct server *s) int xferred = 0; /* The REDISP option was specified. We will ignore cookie and force to - * balance or use the dispatcher. */ - if ((s->proxy->options & (PR_O_REDISP|PR_O_PERSIST)) != PR_O_REDISP) + * balance or use the dispatcher. + */ + if (!(s->cur_admin & SRV_ADMF_MAINT) && + (s->proxy->options & (PR_O_REDISP|PR_O_PERSIST)) != PR_O_REDISP) return 0; HA_SPIN_LOCK(QUEUE_LOCK, &s->queue.lock); @@ -512,7 +514,8 @@ int pendconn_redistribute(struct server *s) /* it's left to the dispatcher to choose a server */ __pendconn_unlink_srv(p); - p->strm_flags &= ~(SF_DIRECT | SF_ASSIGNED); + if (!(s->proxy->options & PR_O_REDISP)) + p->strm_flags &= ~(SF_DIRECT | SF_ASSIGNED); task_wakeup(p->strm->task, TASK_WOKEN_RES); xferred++;