From: Tom Lane <tgl@sss.pgh.pa.us>
To: Robert Haas <robertmhaas@gmail.com>
Cc: pgsql-hackers@postgresql.org <pgsql-hackers@postgresql.org>
Subject: Re: PG_DIAG_SEVERITY and a possible bug in pq_parse_errornotice()
Date: Thu, 25 Aug 2016 15:06:27 -0400
Message-ID: <19757.1472151987@sss.pgh.pa.us> (raw)
In-Reply-To: <15203.1472145555@sss.pgh.pa.us>
References: <A88E0006-13CB-49C6-95CC-1A77D717213C@eggerapps.at>
<11859.1472139831@sss.pgh.pa.us>
<CA+Tgmoa8cbvmet4zBjVggbXkq8uZfHnqL2Nxtv_jTVMKiOwCig@mail.gmail.com>
<15203.1472145555@sss.pgh.pa.us>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>
BTW, this example also exposes another problem, in that the report is
>> ERREUR: unknown error severity
>> CONTEXT: parallel worker
Since, in fact, this error was thrown from leader code, that CONTEXT
report is outright misleading. It's easy to figure that out in this
particular case because the error could only have come from the leader
side, but errors reported from further down inside pq_parse_errornotice
(eg, out-of-memory in pstrdup) would not be so easy.
We could reduce this problem by narrowing the scope over which
HandleParallelMessage activates the ParallelErrorContext callback.
But I'm inclined to get rid of that callback entirely and instead
do something like this:
/* Parse ErrorResponse or NoticeResponse. */
pq_parse_errornotice(msg, &edata);
/* Death of a worker isn't enough justification for suicide. */
edata.elevel = Min(edata.elevel, ERROR);
+ /* If desired, tag the message with context. */
+ if (force_parallel_mode != FORCE_PARALLEL_REGRESS)
+ {
+ if (edata.context)
+ edata.context = psprintf("%s\n%s", edata.context,
+ _("parallel worker"));
+ else
+ edata.context = pstrdup(_("parallel worker"));
+ }
+
/* Rethrow error or notice. */
ThrowErrorData(&edata);
This knows a little bit more than before about the conventions for
combining context strings, but we can be sure that "parallel worker"
will be appended to exactly the messages that come back from the
parallel worker, not anything else.
Barring objections I'll push something like this tomorrow.
regards, tom lane
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-hackers@postgresql.org
Cc: tgl@sss.pgh.pa.us, robertmhaas@gmail.com
Subject: Re: PG_DIAG_SEVERITY and a possible bug in pq_parse_errornotice()
In-Reply-To: <19757.1472151987@sss.pgh.pa.us>
References: <A88E0006-13CB-49C6-95CC-1A77D717213C@eggerapps.at> <11859.1472139831@sss.pgh.pa.us> <CA+Tgmoa8cbvmet4zBjVggbXkq8uZfHnqL2Nxtv_jTVMKiOwCig@mail.gmail.com> <15203.1472145555@sss.pgh.pa.us> <19757.1472151987@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox