From fcb080d8f936f037e6f35960cc0ce3281c8bbc76 Mon Sep 17 00:00:00 2001 From: William Lallemand Date: Tue, 5 Sep 2023 15:25:38 +0200 Subject: [PATCH] MEDIUM: mworker: display a more accessible message when a worker crash Should fix issue #1034. Display a more accessible message when a worker crash about what to do. Example: $ ./haproxy -W -f haproxy.cfg [NOTICE] (308877) : New worker (308884) forked [NOTICE] (308877) : Loading success. [NOTICE] (308877) : haproxy version is 2.9-dev4-d90d3b-58 [NOTICE] (308877) : path to executable is ./haproxy [ALERT] (308877) : Current worker (308884) exited with code 139 (Segmentation fault) [WARNING] (308877) : A worker process unexpectedly died and this can only be explained by a bug in haproxy or its dependencies. Please check that you are running an up to date and maintained version of haproxy and open a bug report. HAProxy version 2.9-dev4-d90d3b-58 2023/09/05 - https://haproxy.org/ Status: development branch - not safe for use in production. Known bugs: https://github.com/haproxy/haproxy/issues?q=is:issue+is:open Running on: Linux 6.2.0-31-generic #31-Ubuntu SMP PREEMPT_DYNAMIC Mon Aug 14 13:42:26 UTC 2023 x86_64 [ALERT] (308877) : exit-on-failure: killing every processes with SIGTERM [WARNING] (308877) : All workers exited. Exiting... (139) --- src/mworker.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/mworker.c b/src/mworker.c index 6bace6b468..b773bfe726 100644 --- a/src/mworker.c +++ b/src/mworker.c @@ -385,10 +385,15 @@ void mworker_catch_sigchld(struct sig_handler *sh) else if (child->options & PROC_O_TYPE_PROG) ha_alert("Current program '%s' (%d) exited with code %d (%s)\n", child->id, exitpid, status, (status >= 128) ? strsignal(status - 128) : "Exit"); - if (status != 0 && status != 130 && status != 143 - && !(global.tune.options & GTUNE_NOEXIT_ONFAILURE)) { - ha_alert("exit-on-failure: killing every processes with SIGTERM\n"); - mworker_kill(SIGTERM); + if (status != 0 && status != 130 && status != 143) { + if (child->options & PROC_O_TYPE_WORKER) { + ha_warning("A worker process unexpectedly died and this can only be explained by a bug in haproxy or its dependencies.\nPlease check that you are running an up to date and maintained version of haproxy and open a bug report.\n"); + display_version(); + } + if (!(global.tune.options & GTUNE_NOEXIT_ONFAILURE)) { + ha_alert("exit-on-failure: killing every processes with SIGTERM\n"); + mworker_kill(SIGTERM); + } } /* 0 & SIGTERM (143) are normal, but we should report SIGINT (130) and other signals */ if (exitcode < 0 && status != 0 && status != 143)