pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Paquier <michael@paquier.xyz>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Set query ID in parallel workers for vacuum, BRIN and btree
Date: Sun, 29 Sep 2024 23:43:44 +0000
Message-ID: <E1sv3Zn-001Uk7-IM@gemulon.postgresql.org> (raw)

Set query ID in parallel workers for vacuum, BRIN and btree

All these code paths use their own entry point when starting parallel
workers, but failed to set a query ID, even if they set a text query.
Hence, this data would be missed in pg_stat_activity for the worker
processes.  The main entry point for parallel query processing,
ParallelQueryMain(), is already doing that by saving its query ID in a
dummy PlannedStmt, but not the others.  The code is changed so as the
query ID of these queries is set in their shared state, and reported
back once the parallel workers start.

Some tests are added to show how the failures can happen for btree and
BRIN with a parallel build enforced, which are able to trigger a failure
in an assertion added by 24f520594809 in the recovery TAP test
027_stream_regress.pl where pg_stat_statements is always loaded.  In
this case, the executor path was taken because the index expression
needs to be flattened when building its IndexInfo.

Alexander Lakhin has noticed the problem in btree, and I have noticed
that the issue was more spread.  This is arguably a bug, but nobody has
complained about that until now, so no backpatch is done out of caution.
If folks would like to see a backpatch, well, let me know.

Reported-by: Alexander Lakhin
Reviewed-by: Sami Imseih
Discussion: https://postgr.es/m/cf3547c1-498a-6a61-7b01-819f902a251f@gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/6fd5071909a2886c499871e61127f815fd9bb6a2

Modified Files
--------------
src/backend/access/brin/brin.c            |  7 +++++++
src/backend/access/nbtree/nbtsort.c       |  7 +++++++
src/backend/commands/vacuumparallel.c     | 11 ++++++++---
src/test/regress/expected/brin.out        | 10 ++++++++++
src/test/regress/expected/btree_index.out | 10 ++++++++++
src/test/regress/sql/brin.sql             | 11 +++++++++++
src/test/regress/sql/btree_index.sql      | 11 +++++++++++
7 files changed, 64 insertions(+), 3 deletions(-)



Message-ID: <E1sv3Zn-001Uk7-IM@gemulon.postgresql.org>
Permalink:  ../E1sv3Zn-001Uk7-IM@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1sv3Zn-001Uk7-IM@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: michael@paquier.xyz, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Set query ID in parallel workers for vacuum, BRIN and btree
  In-Reply-To: <E1sv3Zn-001Uk7-IM@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