From 84dd05e7d83eeee4e7b8c64dc656cdd608c78806 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Wed, 6 Nov 2024 18:10:01 +0100 Subject: [PATCH] DEBUG: wdt: add a stats counter "BlockedTrafficWarnings" in show info Every time a warning is issued about traffic being blocked, let's increment a global counter so that we can check for this situation in "show info". --- include/haproxy/debug.h | 2 ++ include/haproxy/stats-t.h | 1 + src/debug.c | 3 +++ src/stats.c | 2 ++ 4 files changed, 8 insertions(+) diff --git a/include/haproxy/debug.h b/include/haproxy/debug.h index 4bdec78da6..9feed8a99d 100644 --- a/include/haproxy/debug.h +++ b/include/haproxy/debug.h @@ -25,6 +25,8 @@ struct task; struct buffer; extern unsigned int debug_commands_issued; +extern unsigned int warn_blocked_issued; + void ha_task_dump(struct buffer *buf, const struct task *task, const char *pfx); void ha_thread_dump_one(int thr, int from_signal); void ha_dump_backtrace(struct buffer *buf, const char *prefix, int dump); diff --git a/include/haproxy/stats-t.h b/include/haproxy/stats-t.h index 3af6719d48..c58f1aa65e 100644 --- a/include/haproxy/stats-t.h +++ b/include/haproxy/stats-t.h @@ -336,6 +336,7 @@ enum stat_idx_info { ST_I_INF_NICED_TASKS, ST_I_INF_CURR_STRM, ST_I_INF_CUM_STRM, + ST_I_INF_WARN_BLOCKED, /* must always be the last one */ ST_I_INF_MAX diff --git a/src/debug.c b/src/debug.c index 75307dd7be..37f5c8d3cc 100644 --- a/src/debug.c +++ b/src/debug.c @@ -162,6 +162,7 @@ struct post_mortem { } post_mortem ALIGNED(256) HA_SECTION("_post_mortem") = { }; unsigned int debug_commands_issued = 0; +unsigned int warn_blocked_issued = 0; /* dumps a backtrace of the current thread that is appended to buffer . * Lines are prefixed with the string which may be empty (used for @@ -747,6 +748,8 @@ void ha_stuck_warning(int thr) return; } + HA_ATOMIC_INC(&warn_blocked_issued); + buf = b_make(msg_buf, sizeof(msg_buf), 0, 0); p = HA_ATOMIC_LOAD(&ha_thread_ctx[thr].prev_cpu_time); diff --git a/src/stats.c b/src/stats.c index e54141cc00..c3f26b085d 100644 --- a/src/stats.c +++ b/src/stats.c @@ -170,6 +170,7 @@ const struct name_desc stat_cols_info[ST_I_INF_MAX] = { [ST_I_INF_NICED_TASKS] = { .name = "Niced_tasks", .desc = "Total number of active tasks+tasklets in the current worker process (Run_queue) that are niced" }, [ST_I_INF_CURR_STRM] = { .name = "CurrStreams", .desc = "Current number of streams on this worker process" }, [ST_I_INF_CUM_STRM] = { .name = "CumStreams", .desc = "Total number of streams created on this worker process since started" }, + [ST_I_INF_WARN_BLOCKED] = { .name = "BlockedTrafficWarnings", .desc = "Total number of warnings issued about traffic being blocked by too slow a task" }, }; /* one line of info */ @@ -823,6 +824,7 @@ int stats_fill_info(struct field *line, int len, uint flags) line[ST_I_INF_NICED_TASKS] = mkf_u32(0, total_niced_running_tasks()); line[ST_I_INF_CURR_STRM] = mkf_u64(0, glob_curr_strms); line[ST_I_INF_CUM_STRM] = mkf_u64(0, glob_cum_strms); + line[ST_I_INF_WARN_BLOCKED] = mkf_u32(0, warn_blocked_issued); return 1; }