Re: Fixes inconsistent behavior in vacuum when it processes multiple relations

From: Nathan Bossart <nathandbossart(at)gmail(dot)com>
To: shihao zhong <zhong950419(at)gmail(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Fixes inconsistent behavior in vacuum when it processes multiple relations
Date: 2025-06-18 16:31:50
Message-ID: aFLp9sMEHFHULOFx@nathan
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Jun 18, 2025 at 11:15:31AM -0400, shihao zhong wrote:
> I investigated the code and found a small bug with how we're passing
> the VacuumParams pointer.
>
> The call flow is
> ExecVacuum -> vacuum -> vacuum_rel
>
> The initial VaccumParams pointer is set in ExecVacuum
> In vacuum_rel, this pointer might change because it needs to determine
> whether to truncate and perform index_cleanup.

Nice find!

My first reaction is to wonder whether we should 1) also make a similar
change to vacuum() for some future-proofing or 2) just teach vacuum_rel()
to make a local copy of the parameters that it can scribble on. In the
latter case, we might want to assert that the parameters don't change after
calls to vacuum() and vacuum_rel() to prevent this problem from recurring.
That leads me to think (1) might be the better option, although I'm not too
wild about the subtlety of the fix.

--
nathan

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Sergey Sargsyan 2025-06-18 16:33:07 Re: Revisiting {CREATE INDEX, REINDEX} CONCURRENTLY improvements
Previous Message Tom Lane 2025-06-18 16:27:44 Re: minimum Meson version