Re: maximum number of backtrace frames logged by backtrace_functions

From: Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com>
Cc: pgsql-docs(at)lists(dot)postgresql(dot)org
Subject: Re: maximum number of backtrace frames logged by backtrace_functions
Date: 2022-02-04 00:48:58
Message-ID: e312116f-9c44-b7f6-3cfc-4c67f50bbbc7@oss.nttdata.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-docs

On 2022/02/03 23:48, Tom Lane wrote:
> Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com> writes:
>> 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):
>
> +1 for idea (I didn't test it either).

+1. I made this change to the patch and confirmed that it worked fine.

For the record, I tested that by setting backtrace_functions to 'pg_wal_replay_pause' and executing it. This function will report an error when it's called not during recovery.

In the test, "SELECT pg_wal_replay_pause()" caused backtrace but "backtrace limited to %zu frames" message was not output because the number of backtrace frames was less than 100.

Then I created the function "foo" as follows and executed "SELECT foo(0)" to generate more than 100 backtrace frames. In this case "backtrace limited to %zu frames" message was successfully output.

CREATE FUNCTION foo (x int) RETURNS void AS $$
BEGIN
IF x = 10 THEN
PERFORM pg_wal_replay_pause();
ELSE
PERFORM foo(x + 1);
END IF;
END;
$$ LANGUAGE plpgsql;

> Is "nframes" useful enough to
> include in the report?

Probably No because "nframes" is equal to "lengthof(buf)" in the case where more than 100 frames are generated.

Regards,

--
Fujii Masao
Advanced Computing Technology Center
Research and Development Headquarters
NTT DATA CORPORATION

Attachment Content-Type Size
backtrace_limit_report.patch text/plain 510 bytes

In response to

Responses

Browse pgsql-docs by date

  From Date Subject
Next Message Christophe Courtois 2022-02-04 17:52:09 Re: No access to TOAST tables shown in EXPLAIN ( ANALYZE, BUFFERS )
Previous Message Tom Lane 2022-02-03 14:48:16 Re: maximum number of backtrace frames logged by backtrace_functions