Suppressing elog.c context messages (was Re: Wait free LW_SHARED acquisition)

From: Andres Freund <andres(at)2ndquadrant(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Suppressing elog.c context messages (was Re: Wait free LW_SHARED acquisition)
Date: 2014-12-19 16:06:04
Message-ID: 20141219160604.GG5023@alap3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

When debugging lwlock issues I found PRINT_LWDEBUG/LOG_LWDEBUG rather
painful to use because of the amount of elog contexts/statements
emitted. Given the number of lwlock acquirations that's just not doable.

To solve that during development I've solved that by basically
replacing:
if (Trace_lwlocks)
elog(LOG, "%s(%s %d): %s", where, name, index, msg);

with something like

if (Trace_lwlocks)
{
ErrorContextCallback *old_error_context_stack;
...
old_error_context_stack = error_context_stack;
error_context_stack = NULL;
ereport(LOG,
(errhidestmt(true),
errmsg("%s(%s %d): %s", where, T_NAME(lock),
T_ID(lock), msg)));

I think it'd generally be useful to have something like errhidecontext()
akin to errhidestatement() to avoid things like the above.

The usecases wher eI see this as being useful is high volume debug
logging, not normal messages...

Greetings,

Andres Freund

--
Andres Freund http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2014-12-19 16:38:23 Re: NUMERIC private methods?
Previous Message Tom Lane 2014-12-19 15:56:34 Re: NUMERIC private methods?