public inbox for [email protected]
help / color / mirror / Atom feedFrom: Fujii Masao <[email protected]>
To: Tom Lane <[email protected]>
To: Peter Eisentraut <[email protected]>
Cc: [email protected]
Subject: Re: maximum number of backtrace frames logged by backtrace_functions
Date: Fri, 4 Feb 2022 09:48:58 +0900
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
On 2022/02/03 23:48, Tom Lane wrote:
> Peter Eisentraut <[email protected]> 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
diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c
index 7402696986..9933386959 100644
--- a/src/backend/utils/error/elog.c
+++ b/src/backend/utils/error/elog.c
@@ -966,6 +966,9 @@ set_backtrace(ErrorData *edata, int num_skip)
for (int i = num_skip; i < nframes; i++)
appendStringInfo(&errtrace, "\n%s", strfrms[i]);
+ if (nframes >= lengthof(buf))
+ appendStringInfo(&errtrace, "\n(backtrace limited to %zu frames)",
+ lengthof(buf));
free(strfrms);
}
#else
Attachments:
[text/plain] backtrace_limit_report.patch (510B, 2-backtrace_limit_report.patch)
download | inline diff:
diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c
index 7402696986..9933386959 100644
--- a/src/backend/utils/error/elog.c
+++ b/src/backend/utils/error/elog.c
@@ -966,6 +966,9 @@ set_backtrace(ErrorData *edata, int num_skip)
for (int i = num_skip; i < nframes; i++)
appendStringInfo(&errtrace, "\n%s", strfrms[i]);
+ if (nframes >= lengthof(buf))
+ appendStringInfo(&errtrace, "\n(backtrace limited to %zu frames)",
+ lengthof(buf));
free(strfrms);
}
#else
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], [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