Re: PATCH: backtraces for error messages

From: Andres Freund <andres(at)anarazel(dot)de>
To: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
Cc: Craig Ringer <craig(at)2ndquadrant(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: PATCH: backtraces for error messages
Date: 2018-06-20 15:58:28
Message-ID: 20180620155828.2mwdbz6uyjsxwmmr@alap3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On 2018-06-20 11:20:49 -0400, Alvaro Herrera wrote:
> > I recently needed a way to get backtraces from errors in a convenient,
> > non-interactive and indescriminate way. The attached patch is the result.
> > It teaches Pg to use libunwind to self-backtrace in elog/ereport.
> >
> > Anyone think this is useful/interesting/worth pursuing?

Generally interesting, yes.

> I think we sorely need some mechanism to optionally get backtraces in
> error messages. I think having backtraces in all messages is definitely
> not a good thing, but requiring an explicit marker (such as in my patch)
> means the code has to be recompiled, which is not a solution in
> production systems. I kind lean towards your approach, but it has to be
> something that's easily enabled/disabled at runtime.

> I have no idea how expensive backtrace() and libunwind are, but I doubt
> we want to pay the cost for every message before we know that error
> requires the backtrace to be collected. Something like PGC_USERSET
> server_min_backtraces=PANIC
> might be a possible interface.

Yes, most definitely. We can't do this everywhere. It's quite expensive
to collect / build them. So I think we'd probably need another guc that
controls when the information is collected, perhaps defaulting to PANIC.

Greetings,

Andres Freund

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2018-06-20 15:59:57 Re: ERROR: ORDER/GROUP BY expression not found in targetlist
Previous Message Andres Freund 2018-06-20 15:51:48 Re: found xmin from before relfrozenxid on pg_catalog.pg_authid