Parallel vacuum: avoid dangling shared memory pointers
Parallel vacuum: avoid dangling shared memory pointers
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
Re: Parallel vacuum: avoid dangling shared memory pointers
От:
Masahiko Sawada <sawada.mshk@gmail.com>
Дата:
On Tue, Oct 13, 2026 at 8:31 PM Bharath Rupireddy 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
Re: Parallel vacuum: avoid dangling shared memory pointers
От:
Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Дата:
Hi, On Wed, Oct 14, 2026 at 1:31 PM Masahiko Sawada wrote: > > > 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.... > > +1 to explicitly clear these variables. > > Given that it doesn't cause any problems today, I think we can apply > it only to master. Other than keeping the version diff small, I don't have a strong opinion on back-patching it to PG19, as it doesn't fix a bug. So applying it on HEAD looks fine to me. -- Bharath Rupireddy Amazon Web Services: https://aws.amazon.com
Re: Parallel vacuum: avoid dangling shared memory pointers
От:
Masahiko Sawada <sawada.mshk@gmail.com>
Дата:
On Wed, Oct 14, 2026 at 7:19 PM Bharath Rupireddy wrote: > > Hi, > > On Wed, Oct 14, 2026 at 1:31 PM Masahiko Sawada wrote: > > > > > 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.... > > > > +1 to explicitly clear these variables. > > > > Given that it doesn't cause any problems today, I think we can apply > > it only to master. > > Other than keeping the version diff small, I don't have a strong > opinion on back-patching it to PG19, as it doesn't fix a bug. So > applying it on HEAD looks fine to me. I've pushed it to master. Regards, -- Masahiko Sawada Amazon Web Services: https://aws.amazon.com