Re: Parallel vacuum: check XID wraparound failsafe between indexes

From: Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>
To: Sami Imseih <samimseih(dot)pg(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Parallel vacuum: check XID wraparound failsafe between indexes
Date: 2026-10-20 17:09:14
Message-ID: CALj2ACXFUn1RmL2aE0JZp2WANOmMfRToWJTB9LmYKmXRC9kx-g@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On Sat, Oct 17, 2026 at 12:27 PM Sami Imseih <samimseih(dot)pg(at)gmail(dot)com> wrote:
>
> There was probably little incentive to do this for manual VACUUM. Since
> v12, users have been able to disable the main nonessential work
> themselves, e.g. with INDEX_CLEANUP off, TRUNCATE off, etc.

Yes, that's correct. I think it will be more useful for parallel
autovacuum at scale (hundreds of GBs table and indexes) with default
cost delay and cost limit.

> > I chose to set the shared flag in the parallel worker or leader that
> > detects the failsafe, instead of having each one check the failsafe on
> > its own, to avoid taking XidGenLock and MultiXactGenLock so often.
>
> I think the shared flag is the right way. Without it, the only other
> viable place to
> do a recheck would be vacuum_delay_point(), which as you say would mean
> repeatedly taking XidGenLock and MultiXactGenLock locks. I do not think that
> is a good idea.

Right.

> One logging caveat I noticed while testing is that per-index
> VERBOSE/log_autovacuum lines can include indexes vacuumed in an earlier
> pass of the same VACUUM, even if those indexes were skipped in the pass
> in which failsafe is triggered. This is current behavior, so I do not think
> there is anything to do here.

Yeah, that requires some additional tracking and I don't think it's
worth the complexity just for logging.

> But I would suggest one small comment tweak.

Agreed. That looks confusing. I changed it to the following:

/*
* Reset all index status back to initial (while checking that we have
- * vacuumed all indexes).
+ * vacuumed all indexes). Indexes not yet started when the failsafe
+ * triggered are skipped, so those are still NEED_BULKDELETE
here and that
+ * is expected.
*/

> The test also looks necessary to me. No comments on that.

Thanks for reviewing. Please find the attached v2 patch with the above
comment rewording. CF entry:
https://commitfest.postgresql.org/patch/7490/.

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

Attachment Content-Type Size
v2-0001-Check-XID-wraparound-failsafe-between-indexes-in-.patch application/octet-stream 16.7 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Noah Misch 2026-10-20 17:16:56 Re: pg_get_*_ddl() needs a redesign
Previous Message David Geier 2026-10-20 16:59:53 Re: use radix tree for bitmap heap scan