public inbox for [email protected]  
help / color / mirror / Atom feed
From: Peter Eisentraut <[email protected]>
To: Fujii Masao <[email protected]>
To: [email protected]
Subject: Re: maximum number of backtrace frames logged by backtrace_functions
Date: Thu, 3 Feb 2022 10:30:00 +0100
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>
	<[email protected]>
	<[email protected]>

On 03.02.22 06:33, Fujii Masao wrote:
> I encountered the "more than 100 backtrace frames" case when 
> investigating the bug of pg_log_query_plan() patch [1]. Since the 
> function that the patch added can be called repeatedly during call to 
> that function, the backtrace became larger than 100. I think this is not 
> general case, so basically 100 sounds enough limit size to me.
> 
> OTOH I think it's helpful if the limit is documented when I occasionally 
> encounter the case and want to understand why all backtrace frames are 
> not logged.

How about we issue a message when the backtrace is cut off.  Then it's 
immediately visible to the user, instead of hidden away somewhere in the 
documentation.  Something like this (untested):

diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c
index 7402696986..3777dff030 100644
--- a/src/backend/utils/error/elog.c
+++ b/src/backend/utils/error/elog.c
@@ -967,6 +967,8 @@ set_backtrace(ErrorData *edata, int num_skip)
  		for (int i = num_skip; i < nframes; i++)
  			appendStringInfo(&errtrace, "\n%s", strfrms[i]);
  		free(strfrms);
+		if (nframes >= lengthof(buf))
+			appendStringInfo(&errtrace, "\n(backtrace limited to %zu frames)", 
lengthof(buf));
  	}
  #else
  	appendStringInfoString(&errtrace,





reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected]
  Subject: Re: maximum number of backtrace frames logged by backtrace_functions
  In-Reply-To: <[email protected]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox