Re: PG_DIAG_SEVERITY and a possible bug in pq_parse_errornotice() - Mailing list pgsql-hackers

From Tom Lane
Subject Re: PG_DIAG_SEVERITY and a possible bug in pq_parse_errornotice()
Date
Msg-id 6387.1472236121@sss.pgh.pa.us
Whole thread Raw
In response to Re: PG_DIAG_SEVERITY and a possible bug in pq_parse_errornotice()  (Robert Haas <robertmhaas@gmail.com>)
List pgsql-hackers
Robert Haas <robertmhaas@gmail.com> writes:
> On Fri, Aug 26, 2016 at 11:26 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> I'm not quite sure what to do about this.  It feels a tad wrong to use
>> ErrorContext as the active context during HandleParallelMessages, but
>> what else should we use?  Maybe this needs its very own private context
>> that we can reset after each use?

> If we use ErrorContext, will anything go wrong?

I think it might, if we were unlucky enough to be doing this while the
leader was engaged in reporting some other error for its own reasons.
To avoid accumulated memory leakage over multiple worker error reports,
we ought to do a MemoryContextReset at the start or end (probably start)
of HandleParallelMessages, and that would be problematic if ErrorContext
had some data in it already.  It's possible that the scenario can't occur
because CHECK_FOR_INTERRUPTS is never done inside error processing, but
I would not feel very comfortable with that assumption.

I'm thinking a dedicated context is the way to go.  It won't take very
much code.
        regards, tom lane



pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: PG_DIAG_SEVERITY and a possible bug in pq_parse_errornotice()
Next
From: Peter Eisentraut
Date:
Subject: old_snapshot_threshold documentation