Re: Parallel vacuum: avoid dangling shared memory pointers

From: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
To: Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Parallel vacuum: avoid dangling shared memory pointers
Date: 2026-10-14 20:31:09
Message-ID: CAD21AoCs=u3dMvBf+6fwmqdVmmi_=TENrwUGc57OQTnd1XueAQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Oct 13, 2026 at 8:31 PM Bharath Rupireddy
<bharath(dot)rupireddyforpostgres(at)gmail(dot)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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2026-10-14 20:39:10 Re: Wrong results from self-join elimination with inheritance and ONLY
Previous Message Tom Lane 2026-10-14 19:38:57 Re: [PG19] Stale state after the join removal restart gives wrong results