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.
This commit is contained in:
Willy Tarreau 2024-09-27 18:54:07 +02:00
parent a4d04c649a
commit 1385e33eb0

View File

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