Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bczz5-0006U3-DG for pgsql-hackers@arkaria.postgresql.org; Thu, 25 Aug 2016 19:06:39 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1bczz4-0005MZ-Ah for pgsql-hackers@arkaria.postgresql.org; Thu, 25 Aug 2016 19:06:38 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bczz1-0005Ln-RB for pgsql-hackers@postgresql.org; Thu, 25 Aug 2016 19:06:35 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bczyv-0000M6-CI for pgsql-hackers@postgresql.org; Thu, 25 Aug 2016 19:06:34 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id u7PJ6RUP019758; Thu, 25 Aug 2016 15:06:27 -0400 From: Tom Lane To: Robert Haas cc: "pgsql-hackers@postgresql.org" Subject: Re: PG_DIAG_SEVERITY and a possible bug in pq_parse_errornotice() In-reply-to: <15203.1472145555@sss.pgh.pa.us> References: <11859.1472139831@sss.pgh.pa.us> <15203.1472145555@sss.pgh.pa.us> Comments: In-reply-to Tom Lane message dated "Thu, 25 Aug 2016 13:19:15 -0400" Date: Thu, 25 Aug 2016 15:06:27 -0400 Message-ID: <19757.1472151987@sss.pgh.pa.us> X-Pg-Spam-Score: -2.1 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org 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