]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Tighten asserts on ParallelWorkerNumber
authorTomas Vondra <tomas.vondra@postgresql.org>
Sat, 14 Mar 2026 14:24:37 +0000 (15:24 +0100)
committerTomas Vondra <tomas.vondra@postgresql.org>
Sat, 14 Mar 2026 14:31:29 +0000 (15:31 +0100)
commit6fab4fa541a74414b27bed9c01f6e618e793c7d1
treed3c004587cc83034ec184614d28fdbe977e92bc3
parent4f4025eac0b9a8d0b1a4b48db48f770313ea085e
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
src/backend/executor/nodeAgg.c
src/backend/executor/nodeIncrementalSort.c
src/backend/executor/nodeMemoize.c
src/backend/executor/nodeSort.c