Re: Printing backtrace of postgres processes
Alvaro Herrera <alvherre@alvh.no-ip.org>
From: Alvaro Herrera <alvherre@alvh.no-ip.org>
To: vignesh C <vignesh21@gmail.com>
Cc: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>, torikoshia <torikoshia@oss.nttdata.com>,
PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2024-01-26T10:41:04Z
Lists: pgsql-hackers
On 2022-Jan-27, vignesh C wrote:
> diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml
> index 0ee6974f1c..855ccc8902 100644
> --- a/doc/src/sgml/func.sgml
> +++ b/doc/src/sgml/func.sgml
> + You can get the file name and line number from the logged details by using
> + gdb/addr2line in linux platforms (users must ensure gdb/addr2line is
> + already installed).
This doesn't read great. I mean, what is gdb/addr2line? I think you
mean either GDB or addr2line; this could be clearer.
> diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c
> index 7402696986..522a525741 100644
> --- a/src/backend/utils/error/elog.c
> +++ b/src/backend/utils/error/elog.c
> @@ -944,9 +943,10 @@ errbacktrace(void)
> * Compute backtrace data and add it to the supplied ErrorData. num_skip
> * specifies how many inner frames to skip. Use this to avoid showing the
> * internal backtrace support functions in the backtrace. This requires that
> - * this and related functions are not inlined.
> + * this and related functions are not inlined. If the edata pointer is valid,
> + * backtrace information will be set in edata.
> */
> -static void
> +void
> set_backtrace(ErrorData *edata, int num_skip)
> {
> StringInfoData errtrace;
This seems like a terrible API choice, and the comment change is no
good. I suggest you need to create a function that deals only with a
StringInfo, maybe
append_backtrace(StringInfo buf, int num_skip)
which is used by set_backtrace to print the backtrace in
edata->backtrace, and a new function log_backtrace() that does the
ereport(LOG_SERVER_ONLY) thing.
--
Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/
"Before you were born your parents weren't as boring as they are now. They
got that way paying your bills, cleaning up your room and listening to you
tell them how idealistic you are." -- Charles J. Sykes' advice to teenagers
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