pgsql: Fix crash in parallel autovacuum when no DSM segment can be crea

From: Masahiko Sawada <msawada(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix crash in parallel autovacuum when no DSM segment can be crea
Date: 2026-09-28 23:28:48
Message-ID: E1xBKm8-00000001flg-1lrs@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix crash in parallel autovacuum when no DSM segment can be created.

If no DSM segment can be created, a ParallelContext can still be
created with zero workers, but its seg pointer is NULL. Parallel
autovacuum registered a segment detach callback on that NULL pointer,
crashing the autovacuum worker.

Fix by setting up the shared cost parameters and the detach callback
only when the parallel context has workers, as there are no workers to
propagate the parameters to otherwise.

Oversight in commit 1ff3180ca01.

Found by Bharath using AI assisted review with Claude.

Reported-by: Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>
Author: Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>
Discussion: https://postgr.es/m/CALj2ACVjBN03Fq4XWgKH1zOfkapK6-P3ufNLHUHnZcW1zPm+Mg@mail.gmail.com
Backpatch-through: 19

Branch
------
REL_19_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/4331d20f4d5cb51663b0912fdb2a3b991bc5a5c8

Modified Files
--------------
src/backend/commands/vacuumparallel.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message David Rowley 2026-09-29 02:48:35 pgsql: Fix incorrect calcSumX2 in numeric deserialize functions
Previous Message Masahiko Sawada 2026-09-28 23:28:44 pgsql: Fix crash in parallel autovacuum when no DSM segment can be crea