]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: pools: Don't dump anymore info about pools when purge is forced
authorChristopher Faulet <cfaulet@haproxy.com>
Mon, 8 Sep 2025 13:44:06 +0000 (15:44 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Mon, 8 Sep 2025 14:04:40 +0000 (16:04 +0200)
Historically, when the purge of pools was forced by sending a SIGQUIT to
haproxy, information about the pools were first dumped. It is now totally
pointless because these info can be retrieved via the CLI. It is even less
relevant now because the purge is forced typically when there are memroy
issues and to dump pools information, data must be allocated.

dump_pools_info() function was simplified because it is now called only from
an applet. No reason to still try to dump info on stderr.

doc/management.txt
include/haproxy/pool.h
src/haproxy.c
src/pool.c

index 19ba7f00cceafb47dbebc93d4c25c1cedeb896e7..c866148cb2875cd6750064a020f76343894dbd1b 100644 (file)
@@ -900,9 +900,7 @@ If a memory allocation fails due to the memory limit being reached or because
 the system doesn't have any enough memory, then haproxy will first start to
 free all available objects from all pools before attempting to allocate memory
 again. This mechanism of releasing unused memory can be triggered by sending
-the signal SIGQUIT to the haproxy process. When doing so, the pools state prior
-to the flush will also be reported to stderr when the process runs in
-foreground.
+the signal SIGQUIT to the haproxy process.
 
 During a reload operation, the process switched to the graceful stop state also
 automatically performs some flushes after releasing any connection so that all
index 3fd82390b79207537fffb7b5bd942a02dd48006f..a1e7be70985a914d399e546fb89c4f59b9ef589c 100644 (file)
@@ -177,7 +177,6 @@ void *pool_get_from_os_noinc(struct pool_head *pool);
 void pool_put_to_os_nodec(struct pool_head *pool, void *ptr);
 void *pool_alloc_nocache(struct pool_head *pool, const void *caller);
 void pool_free_nocache(struct pool_head *pool, void *ptr);
-void dump_pools(void);
 int pool_parse_debugging(const char *str, char **err);
 int pool_total_failures(void);
 unsigned long long pool_total_allocated(void);
index 5f89ddd7940b669e24bfd7e75b8830eccfa89e23..ab17fee6bfc64bf95286812fc1ad266801f02961 100644 (file)
@@ -895,8 +895,7 @@ static void sig_dump_state(struct sig_handler *sh)
 
 static void dump(struct sig_handler *sh)
 {
-       /* dump memory usage then free everything possible */
-       dump_pools();
+       /* free everything possible */
        pool_gc(NULL);
 }
 
index 730834c9d61dea583eb606283920e40f6b577f73..d7928c37cfdb97bff1ed97a86440b05317adcacd 100644 (file)
@@ -1348,11 +1348,11 @@ static int get_show_pools_info(struct show_pools_ctx *ctx)
        return 0;
 }
 
-/* This function dumps information about pools found in the context <ctx>. If
- * <appctx> is NULL, it dumps it on stderr. Otherwise the applet is used.
+/* This function dumps information about pools found in the applet context.
  */
-int dump_pools_info(struct appctx *appctx, struct show_pools_ctx *ctx)
+int dump_pools_info(struct appctx *appctx)
 {
+       struct show_pools_ctx *ctx = appctx->svcctx;
        int i;
 
        if (ctx->pool_idx == -1) {
@@ -1361,9 +1361,7 @@ int dump_pools_info(struct appctx *appctx, struct show_pools_ctx *ctx)
                        chunk_appendf(&trash, " (limited to the first %u entries)", ctx->maxcnt);
                chunk_appendf(&trash, ". Use SIGQUIT to flush them.\n");
 
-               if (!appctx)
-                       qfprintf(stderr, "%s", trash.area);
-               else if (applet_putchk(appctx, &trash) == -1)
+               if (applet_putchk(appctx, &trash) == -1)
                        return 0;
 
                ctx->pool_idx = 0;
@@ -1391,9 +1389,7 @@ int dump_pools_info(struct appctx *appctx, struct show_pools_ctx *ctx)
                        }
                }
 
-               if (!appctx)
-                       qfprintf(stderr, "%s", trash.area);
-               else if (applet_putchk(appctx, &trash) == -1) {
+               if (applet_putchk(appctx, &trash) == -1) {
                        ctx->pool_idx = i;
                        return 0;
                }
@@ -1404,27 +1400,12 @@ int dump_pools_info(struct appctx *appctx, struct show_pools_ctx *ctx)
                     ".\n",
                     ctx->nbpools, ctx->allocated, ctx->used, ctx->cached_bytes
                );
-       if (!appctx)
-               qfprintf(stderr, "%s", trash.area);
-       else  if (applet_putchk(appctx, &trash) == -1)
+       if (applet_putchk(appctx, &trash) == -1)
                return 0;
 
        return 1;
 }
 
-/* Dump statistics on pools usage. */
-void dump_pools(void)
-{
-       struct show_pools_ctx ctx;
-
-       memset(&ctx, 0, sizeof(ctx));
-
-       if (get_show_pools_info(&ctx) == -1) {
-               qfprintf(stderr, "Failed to get info about pools.\n");
-       }
-       dump_pools_info(NULL, &ctx);
-}
-
 /* This function returns the total number of failed pool allocations */
 int pool_total_failures()
 {
@@ -1613,9 +1594,7 @@ static void cli_release_show_pools(struct appctx *appctx)
  */
 static int cli_io_handler_dump_pools(struct appctx *appctx)
 {
-       struct show_pools_ctx *ctx = appctx->svcctx;
-
-       return dump_pools_info(appctx, ctx);
+       return dump_pools_info(appctx);
 }
 
 /* callback used to create early pool <name> of size <size> and store the