MEDIUM: mworker: block reloads

When reloads arrive very often (sent by some APIs), newly forked workers
almost don't have a time to load completely and to send its READY status to
master, which allows then to stop the previous worker (launched before reload).
As a result, the number of workers increases very quickly, previous workers are
still alive and the memory consumption is very high.

To avoid such situations let's return in cli_parse_reload() reload status 0
with the text ""Another reload is still in progress", if there is still a
process with PROC_O_INIT flag in the processes list.
This commit is contained in:
Valentine Krasnobaeva 2024-10-09 19:23:41 +02:00 committed by Willy Tarreau
parent 5be14b338a
commit 5f16453082

View File

@ -699,10 +699,27 @@ static int cli_parse_reload(char **args, char *payload, struct appctx *appctx, v
struct connection *conn = NULL;
int fd = -1;
int hardreload = 0;
struct mworker_proc *proc;
if (!cli_has_level(appctx, ACCESS_LVL_OPER))
return 1;
list_for_each_entry(proc, &proc_list, list) {
/* if there is a process with PROC_O_INIT, i.e. new worker is
* doing its init routine, block the reload
*/
if (proc->options & PROC_O_INIT) {
chunk_printf(&trash, "Success=0\n");
chunk_appendf(&trash, "--\n");
chunk_appendf(&trash, "Another reload is still in progress.\n");
if (applet_putchk(appctx, &trash) == -1)
return 0;
return 1;
}
}
/* hard reload requested */
if (*args[0] == 'h')
hardreload = 1;