Parallel vacuum: avoid dangling shared memory pointers

Started by Bharath Rupireddyabout 20 hours ago2 messageshackers
Beta feature

Hackorum builds and tests every patch posted to the lists, not only commitfest submissions. This is Hackorum's own CI rather than the PostgreSQL project's, and it is still under testing - please report anything that looks wrong.

appliessuccessCI history

You can run a PostgreSQL built from this patch straight from Docker, with no checkout and no build:

docker run --rm -p 5432:5432 ghcr.io/hackorum-dev/postgres-patch:t254190
psql -h localhost -U postgres

Built from patchset v1 (message #1), October 14, 2026 at 03:42 AM.

Every patchset is also pushed to a branch of our PostgreSQL fork, so you can check out the same tree CI built. Without a PostgreSQL checkout:

git clone --branch t254190_1 https://github.com/hackorum-dev/postgres.git

In a checkout you already have, add the fork once:

git remote add hackorum https://github.com/hackorum-dev/postgres.git

then, for this patchset and every later one:

git fetch hackorum t254190_1 && git checkout t254190_1

Patchset v1 (message #1) is on t254190_1

Jump to latest
#1Bharath Rupireddy
bharath.rupireddyforpostgres@gmail.com

Hi,

I noticed that two of the parallel vacuum's shared memory pointers
(VacuumSharedCostBalance and VacuumActiveNWorkers) are not reset on
the error path, leaving them dangling, that is, pointing to a shared
memory segment that is already gone, until the next vacuum runs in the
backend or autovacuum worker. This doesn't cause any issue today, but
IMHO it is good practice to avoid dangling pointers.

Please find the attached patch that sets them to NULL on the error
path (the normal path resets them in
parallel_vacuum_process_all_indexes()).

Thoughts?

--
Bharath Rupireddy
Amazon Web Services: https://aws.amazon.com

Attachments:

t254190_1
v1-0001-Avoid-dangling-shared-memory-pointers-in-parallel.patchapplication/x-patch; name=v1-0001-Avoid-dangling-shared-memory-pointers-in-parallel.patchDownload+3-1
#2Masahiko Sawada
sawada.mshk@gmail.com
In reply to: Bharath Rupireddy (#1)
Re: Parallel vacuum: avoid dangling shared memory pointers

On Tue, Oct 13, 2026 at 8:31 PM Bharath Rupireddy
<bharath.rupireddyforpostgres@gmail.com> wrote:

Hi,

I noticed that two of the parallel vacuum's shared memory pointers
(VacuumSharedCostBalance and VacuumActiveNWorkers) are not reset on
the error path, leaving them dangling, that is, pointing to a shared
memory segment that is already gone, until the next vacuum runs in the
backend or autovacuum worker. This doesn't cause any issue today, but
IMHO it is good practice to avoid dangling pointers.

Please find the attached patch that sets them to NULL on the error
path (the normal path resets them in
parallel_vacuum_process_all_indexes()).

Thoughts?

+1 to explicitly clear these variables.

Given that it doesn't cause any problems today, I think we can apply
it only to master.

Regards,

--
Masahiko Sawada
Amazon Web Services: https://aws.amazon.com