]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: mworker: block reloads
authorValentine Krasnobaeva <vkrasnobaeva@haproxy.com>
Wed, 9 Oct 2024 17:23:41 +0000 (19:23 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 16 Oct 2024 20:02:39 +0000 (22:02 +0200)
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.

src/mworker.c

index 431935852cc2213f0532d66bda70df305493601f..7d3c831c975d8018418bb8afdf5b3a9023cb33d0 100644 (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;