Re: Printing backtrace of postgres processes

From: shihao zhong <zhong950419(at)gmail(dot)com>
To: Michael Paquier <michael(at)paquier(dot)xyz>
Cc: Christoph Berg <myon(at)debian(dot)org>, Ashutosh Bapat <ashutosh(dot)bapat(dot)oss(at)gmail(dot)com>, Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>, vignesh C <vignesh21(at)gmail(dot)com>, torikoshia <torikoshia(at)oss(dot)nttdata(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Printing backtrace of postgres processes
Date: 2026-12-05 15:55:25
Message-ID: CAGRkXqT7uknBXEmLzSYAg5ffr2=+1NDgE-zrx_DtYtzEM+38HA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Michael,

I found this thread while debugging a stuck startup process and
parallel worker.

On the cost, I loaded libgcc once in the postmaster as Christoph
suggested. pgbench -C gives 4696 tps on master, 4660 with that.

On safety, you were right. With JIT, a signal that lands inside
__register_frame() makes backtrace() spin forever in
_Unwind_Find_FDE(). With gdb, 11 of 250 points in that call hang on
libgcc 14.

So I would do it at CFI. But a process stuck on an LWLock never gets
there. For that the attached prototype calls clone() in the handler,
and the copy calls backtrace(). If the copy hangs, an alarm kills
it and the backend goes on. A second request gave the backtrace.

The prototype always clones. A real patch would only clone when the
process does not get to CFI.

Given clone is Linux only we may need to see if other os have similar API,
What do you think?

Thanks,
Shihao

Attachment Content-Type Size
nocfbot-0001-PROTOTYPE-log-backtrace-from-cloned-copy.patch.txt text/plain 13.3 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Alexander Lakhin 2026-12-05 16:00:00 003_standby_restarts.pl fails on thorntail due to sparc-linux-ext4-specific bug
Previous Message Rui Zhao 2026-12-05 15:53:40 Re: Avoid logging dropped TOAST values with REPLICA IDENTITY FULL