Re: Printing backtrace of postgres processes
Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
From: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
To: Michael Paquier <michael@paquier.xyz>
Cc: Alvaro Herrera <alvherre@alvh.no-ip.org>, Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>,
vignesh C <vignesh21@gmail.com>, torikoshia <torikoshia@oss.nttdata.com>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2024-02-13T14:02:28Z
Lists: pgsql-hackers
On Mon, Feb 12, 2024 at 6:52 AM Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> wrote: > > > > > > We defer actual action triggered by a signal till CHECK_FOR_INTERRUPTS > > > is called. I understand that we can't do that here since we want to > > > capture the backtrace at that moment and can't wait till next CFI. But > > > printing the backend can surely wait till next CFI right? > > > > Delaying the call of backtrace() to happen during a CFI() would be > > safe, yes, and writing data to stderr would not really be an issue as > > at least the data would be sent somewhere. That's less useful, but > > we do that for memory contexts. > > Memory contexts do not change more or less till next CFI, but stack > traces do. So I am not sure whether it is desirable to wait to capture > backtrace till next CFI. Given that the user can not time a call to > pg_log_backend() exactly, so whether it captures the backtrace exactly > at when interrupt happens or at the next CFI may not matter much in > practice. > Thinking more about this I have following thoughts/questions: 1. Whether getting a backtrace at CFI is good enough? Backtrace is required to know what a process is doing when it's stuck or is behaviour unexpected etc. PostgreSQL code has CFIs sprinkled in almost all the tight loops. Whether those places are enough to cover most of the cases that the user of this feature would care about? 2. tools like gdb, strace can be used to get the stack trace of any process, so do we really need this tool? Most of the OSes provide such tools but may be there are useful in kubernetes like environment, I am not sure. 3. tools like gdb and strace are able to capture stack trace at any point during execution. Can we use the same mechanism instead of relying on CFI? 4. tools like gdb and strace can capture more than just stack trace e.g. variable values, values of registers etc. Are we planning to add those facilities as well? OR whether this feature will be useful without those facilities? May the feature be more useful if it can provide PostgreSQL specific details which an external tool can not. -- Best Wishes, Ashutosh Bapat
Commits
-
Perform apply of large transactions by parallel workers.
- 216a784829c2 16.0 cited
-
Enhance pg_log_backend_memory_contexts() for auxiliary processes.
- 790fbda90209 15.0 cited
-
Allow GRANT on pg_log_backend_memory_contexts().
- f0b051e322d5 15.0 cited
-
Move Perl test modules to a better namespace
- b3b4d8e68ae8 15.0 cited
-
Unify PostgresNode's new() and get_new_node() methods
- 201a76183e20 15.0 cited
-
Add backtrace support for error reporting
- 71a8a4f6e365 13.0 cited