1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-26 12:21:12 +03:00

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
This commit is contained in:
Peter Eisentraut
2023-12-30 11:11:26 +01:00
parent 9d49837d71
commit a740b213d4
4 changed files with 44 additions and 3 deletions

View File

@ -527,6 +527,7 @@ int log_temp_files = -1;
double log_statement_sample_rate = 1.0;
double log_xact_sample_rate = 0;
char *backtrace_functions;
bool backtrace_on_internal_error = false;
int temp_file_limit = -1;
@ -812,6 +813,16 @@ StaticAssertDecl(lengthof(config_type_names) == (PGC_ENUM + 1),
struct config_bool ConfigureNamesBool[] =
{
{
{"backtrace_on_internal_error", PGC_SUSET, DEVELOPER_OPTIONS,
gettext_noop("Log backtrace for any error with error code XX000 (internal error)."),
NULL,
GUC_NOT_IN_SAMPLE
},
&backtrace_on_internal_error,
false,
NULL, NULL, NULL
},
{
{"enable_seqscan", PGC_USERSET, QUERY_TUNING_METHOD,
gettext_noop("Enables the planner's use of sequential-scan plans."),