Skip to content

Commit 4adb2d8

Browse files
committed
MINOR: debug: do not limit backtraces to stuck threads
Historically for size limitation reasons, we would only dump the backtrace of stuck threads. The problem is that when triggering a panic or other reasons, we have no backtrace, which effectively limits it to the watchdog timer. It's also visible in "show threads" which used to report backtraces for all threads in 2.4 and displays none nowadays, making its use much more limited. A first approach could be to just dump the thread that triggers the panic (in addition to stuck threads). But that remains quite limited since "show threads" would still display nothing. This patch takes a better approach consisting in dumping all non-idle threads. This way the output is less polluted that with the older approach (no need to dump all those waiting in the poller), and all active threads are visible, in panics as well as in "show threads". As such, the CLI command "debug dev panic" now dmups backtraces again. This is already a benefit which will ease testing of various locations against the ability to resolve useful symbols.
1 parent e5fccfe commit 4adb2d8

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

src/debug.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,8 @@ void ha_thread_dump_one(int thr, int from_signal)
322322
chunk_appendf(buf, " curr_task=");
323323
ha_task_dump(buf, th_ctx->current, " ");
324324

325-
if (stuck && thr == tid) {
325+
if (thr == tid && !(HA_ATOMIC_LOAD(&tg_ctx->threads_idle) & ti->ltid_bit)) {
326+
/* only dump the stack of active threads */
326327
#ifdef USE_LUA
327328
if (th_ctx->current &&
328329
th_ctx->current->process == process_stream && th_ctx->current->context) {
@@ -346,12 +347,6 @@ void ha_thread_dump_one(int thr, int from_signal)
346347
if (HA_ATOMIC_LOAD(&pool_trim_in_progress))
347348
mark_tainted(TAINTED_MEM_TRIMMING_STUCK);
348349

349-
/* We only emit the backtrace for stuck threads in order not to
350-
* waste precious output buffer space with non-interesting data.
351-
* Please leave this as the last instruction in this function
352-
* so that the compiler uses tail merging and the current
353-
* function does not appear in the stack.
354-
*/
355350
ha_dump_backtrace(buf, " ", 0);
356351
}
357352
leave:

0 commit comments

Comments
 (0)