pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tomas Vondra <tomas.vondra@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Tighten asserts on ParallelWorkerNumber
Date: Sat, 14 Mar 2026 14:48:37 +0000
Message-ID: <E1w1QI8-0008V4-0L@gemulon.postgresql.org> (raw)

Tighten asserts on ParallelWorkerNumber

The comment about ParallelWorkerNumbr in parallel.c says:

  In parallel workers, it will be set to a value >= 0 and < the number
  of workers before any user code is invoked; each parallel worker will
  get a different parallel worker number.

However asserts in various places collecting instrumentation allowed
(ParallelWorkerNumber == num_workers). That would be a bug, as the value
is used as index into an array with num_workers entries.

Fixed by adjusting the asserts accordingly. Backpatch to all supported
versions.

Discussion: https://postgr.es/m/5db067a1-2cdf-4afb-a577-a04f30b69167@vondra.me
Reviewed-by: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Backpatch-through: 14

Branch
------
REL_15_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/34baa313e31788e3a0ba251d5649b6e3ccfced26

Modified Files
--------------
src/backend/executor/nodeAgg.c             | 2 +-
src/backend/executor/nodeIncrementalSort.c | 2 +-
src/backend/executor/nodeMemoize.c         | 2 +-
src/backend/executor/nodeSort.c            | 2 +-
4 files changed, 4 insertions(+), 4 deletions(-)



view thread (6+ messages)  latest in thread

Message-ID: <E1w1QI8-0008V4-0L@gemulon.postgresql.org>
Permalink:  ../E1w1QI8-0008V4-0L@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1w1QI8-0008V4-0L@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: tomas.vondra@postgresql.org, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Tighten asserts on ParallelWorkerNumber
  In-Reply-To: <E1w1QI8-0008V4-0L@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