Re: Parallel vacuum: check XID wraparound failsafe between indexes

From: Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>
To: surya poondla <suryapoondla4(at)gmail(dot)com>
Cc: Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org, Sami Imseih <samimseih(dot)pg(at)gmail(dot)com>
Subject: Re: Parallel vacuum: check XID wraparound failsafe between indexes
Date: 2026-11-20 02:56:54
Message-ID: CALj2ACUNN-E_ZPRXg578C0wO93EbNaa-Z=0hyhjC7ryoqyCqtw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On Wed, Nov 18, 2026 at 9:29 AM Bharath Rupireddy
<bharath(dot)rupireddyforpostgres(at)gmail(dot)com> wrote:
>
> On Mon, Nov 9, 2026 at 3:13 PM surya poondla <suryapoondla4(at)gmail(dot)com> wrote:
>
> > 1. v3 now runs lazy_check_wraparound_failsafe() after the parallel index
> > pass only when the shared flag is set;
>
> > matters in one corner case which is parallel workers use the GUC values
> > serialized when the parallel context was set up, while an autovacuum
> > leader can reload vacuum_failsafe_age while it waits for them. If
> > vacuum_failsafe_age is lowered at that point, only the leader's recheck
> > would notice it. I can share a reproducer if that's useful (doesn't happen in normal scenarios)
>
> Yeah, that's right. And that window, where users can lower the
> failsafe age to avoid wraparound, can be long in some cases. This can
> happen when the leader waits for the workers to finish index vacuuming
> (i.e. the leader gets small indexes compared to the workers).
>
> I don't think the fix is to keep an extra check in the leader. The
> issue is that we don't pass the failsafe age down to the workers like
> we do for the other cost delay params. Without it, the workers can't
> honor a changed failsafe age, and lowering it can be a valid way to
> avoid wraparound.
>
> So I think a better fix is to pass the failsafe age from the leader to
> the workers. That way both the leader and the workers check after each
> index. If the leader is waiting for the workers and the failsafe age
> changes, the workers will catch it, set the shmem flag, and the leader
> will report it. So we wouldn't need an extra check in the leader.

Please find the attached v4 patch with the above change.

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

Attachment Content-Type Size
v4-0001-Check-XID-wraparound-failsafe-between-indexes-in-.patch application/x-patch 23.7 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Chengpeng Yan 2026-11-20 03:05:03 Re: [PATCH] Fix encoding-dependent LIKE/regex selectivity estimates
Previous Message Lukas Fittl 2026-11-20 02:54:02 Re: Parallel GIN, BRIN builds fail to maintain ii_BrokenHotChain