pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix contrib/auto_explain to not cause problems in parallel worke
Date: Mon, 03 Jun 2019 22:06:21 +0000
Message-ID: <E1hXv5x-0002VT-Gs@gemulon.postgresql.org> (raw)

Fix contrib/auto_explain to not cause problems in parallel workers.

A parallel worker process should not be making any decisions of its
own about whether to auto-explain.  If the parent session process
passed down flags asking for instrumentation data, do that, otherwise
not.  Trying to enable instrumentation anyway leads to bugs like the
"could not find key N in shm TOC" failure reported in bug #15821
from Christian Hofstaedtler.

We can implement this cheaply by piggybacking on the existing logic
for not doing anything when we've chosen not to sample a statement.

While at it, clean up some tin-eared coding related to the sampling
feature, including an off-by-one error that meant that asking for 1.0
sampling rate didn't actually result in sampling every statement.

Although the specific case reported here only manifested in >= v11,
I believe that related misbehaviors can be demonstrated in any version
that has parallel query; and the off-by-one error is certainly there
back to 9.6 where that feature was added.  So back-patch to 9.6.

Discussion: https://postgr.es/m/15821-5eb422e980594075@postgresql.org

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/2cd4e835701e15f5e32dd8bde488f8669ddf7ae8

Modified Files
--------------
contrib/auto_explain/auto_explain.c | 43 ++++++++++++++++++++++++-------------
1 file changed, 28 insertions(+), 15 deletions(-)



view thread (7+ messages)  latest in thread

Message-ID: <E1hXv5x-0002VT-Gs@gemulon.postgresql.org>
Permalink:  ../E1hXv5x-0002VT-Gs@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1hXv5x-0002VT-Gs@gemulon.postgresql.org

 · 

reply

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 using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Fix contrib/auto_explain to not cause problems in parallel worke
  In-Reply-To: <E1hXv5x-0002VT-Gs@gemulon.postgresql.org>

* 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