pgsql: Fix crash in parallel autovacuum when no DSM segment can be crea - Mailing list pgsql-committers

From Masahiko Sawada
Subject pgsql: Fix crash in parallel autovacuum when no DSM segment can be crea
Date
Msg-id E1xBKm4-00000001fl5-2ty5@gemulon.postgresql.org
Whole thread
List 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.rupireddyforpostgres@gmail.com>
Author: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Discussion: https://postgr.es/m/CALj2ACVjBN03Fq4XWgKH1zOfkapK6-P3ufNLHUHnZcW1zPm+Mg@mail.gmail.com
Backpatch-through: 19

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/cc053b6e127763e4168f18585ca90a67600c270e

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


pgsql-committers by date:

Previous
From: Nathan Bossart
Date:
Subject: pgsql: Better express platform requirements in s_lock.h.
Next
From: Masahiko Sawada
Date:
Subject: pgsql: Fix crash in parallel autovacuum when no DSM segment can be crea