digoal
2024-01-01
PostgreSQL , PolarDB , DuckDB , XX000 , backtrace_on_internal_error , internal error
Add GUC backtrace_on_internal_error
author Peter Eisentraut <peter@eisentraut.org>
Sat, 30 Dec 2023 10:11:26 +0000 (11:11 +0100)
committer Peter Eisentraut <peter@eisentraut.org>
Sat, 30 Dec 2023 10:43:57 +0000 (11:43 +0100)
commit a740b213d4b4d3360ad0cac696e47e5ec0eb8864
tree 3a685f9b8eb1b6b7599ddb7926647f2ade4c5e59 tree
parent 9d49837d7144e27ad8ea8918acb28f9872cb1585 commit | diff
Add GUC backtrace_on_internal_error
When enabled (default off), this logs a backtrace anytime elog() or an
equivalent ereport() for internal errors is called.
This is not well covered by the existing backtrace_functions, because
there are many equally-worded low-level errors in many functions. And
if you find out where the error is, then you need to manually rewrite
the elog() to ereport() to attach the errbacktrace(), which is
annoying. Having a backtrace automatically on every elog() call could
be very helpful during development for various kinds of common errors
from palloc, syscache, node support, etc.
Discussion: https://www.postgresql.org/message-id/flat/ba76c6bc-f03f-4285-bf16-47759cfcab9e@eisentraut.org
+ <varlistentry id="guc-backtrace-on-internal-error" xreflabel="backtrace_on_internal_error">
+ <term><varname>backtrace_on_internal_error</varname> (<type>boolean</type>)
+ <indexterm>
+ <primary><varname>backtrace_on_internal_error</varname> configuration parameter</primary>
+ </indexterm>
+ </term>
+ <listitem>
+ <para>
+ If this parameter is on and an error with error code XX000 (internal
+ error; see also <xref linkend="errcodes-appendix"/>) is raised, then a
+ backtrace is written to the server log together with the error
+ message. This can be used to debug such internal errors (which should
+ normally not happen in production). The default is off.
+ </para>
+
+ <para>
+ Backtrace support is not available on all platforms, and the quality
+ of the backtraces depends on compilation options.
+ </para>
+
+ <para>
+ Only superusers and users with the appropriate <literal>SET</literal>
+ privilege can change this setting.
+ </para>
+ </listitem>
+ </varlistentry>