From 71a31fc3ec25590f6a799118a923ab6366a37ad0 Mon Sep 17 00:00:00 2001
From: Jelte Fennema-Nio <jelte.fennema@microsoft.com>
Date: Fri, 22 Mar 2024 10:58:53 +0100
Subject: [PATCH v9 3/3] Change log_backtrace default to "internal"

Internal errors should not happen in production. When they do it is
likely a bug and it can be very useful to have a backtrace when trying
to determine it's exact cause. This changes the default for
log_backtrace to "internal" so that the bug reports we receive are much
more likely to include such a backtrace.
---
 doc/src/sgml/config.sgml            | 4 ++--
 src/backend/utils/error/elog.c      | 2 +-
 src/backend/utils/misc/guc_tables.c | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml
index b315c84ce98..223442afbe5 100644
--- a/doc/src/sgml/config.sgml
+++ b/doc/src/sgml/config.sgml
@@ -7280,12 +7280,12 @@ local0.*    /var/log/postgresql
        <para>
         If this parameter is set to <literal>all</literal> then for all log
         entries a backtrace is written to the server log together with the log
-        message. If this parameter is set to <literal>internal</literal> then
+        message. If this parameter is set to <literal>internal</literal> (the default) then
         such a backtrace is only written for logs with error code XX000
         (internal error; see also <xref linkend="errcodes-appendix"/>).
         This can be used to debug such internal errors (which should normally
         not happen in production). Finally, if this parameter is set to
-        <literal>none</literal> (the default), no backtraces are ever written
+        <literal>none</literal>, no backtraces are ever written
         to the server log.
        </para>
 
diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c
index 8f6a107d285..c199538e270 100644
--- a/src/backend/utils/error/elog.c
+++ b/src/backend/utils/error/elog.c
@@ -111,7 +111,7 @@ int			Log_error_verbosity = PGERROR_DEFAULT;
 char	   *Log_line_prefix = NULL; /* format for extra log line info */
 int			Log_destination = LOG_DESTINATION_STDERR;
 char	   *Log_destination_string = NULL;
-int			log_backtrace = LOGBACKTRACE_NONE;
+int			log_backtrace = LOGBACKTRACE_INTERNAL;
 bool		syslog_sequence_numbers = true;
 bool		syslog_split_messages = true;
 
diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c
index f6f4f0521e8..f2a79a0980a 100644
--- a/src/backend/utils/misc/guc_tables.c
+++ b/src/backend/utils/misc/guc_tables.c
@@ -4834,7 +4834,7 @@ struct config_enum ConfigureNamesEnum[] =
 			NULL
 		},
 		&log_backtrace,
-		LOGBACKTRACE_NONE, log_backtrace_options,
+		LOGBACKTRACE_INTERNAL, log_backtrace_options,
 		NULL, NULL, NULL
 	},
 
-- 
2.34.1

