Re: RelationGetNumberOfBlocks called before vacuum_get_cutoffs

From: Melanie Plageman <melanieplageman(at)gmail(dot)com>
To: Peter Geoghegan <pg(at)bowt(dot)ie>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: RelationGetNumberOfBlocks called before vacuum_get_cutoffs
Date: 2025-06-01 17:51:06
Message-ID: CAAKRu_aKxcfgrLw54QcphdreddEZL-CFsbPU=tOvbd9S6GVKVA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sun, Jun 1, 2025 at 12:07 PM Peter Geoghegan <pg(at)bowt(dot)ie> wrote:
>
> Commit 052026c9b9 made heap_vacuum_rel call RelationGetNumberOfBlocks
> before it calls vacuum_get_cutoffs -- it swapped the order. This is
> wrong, as explained by an intact comment above the call to
> vacuum_get_cutoffs.
>
> In short, there is now a brief window during which the relation can be
> extended that'll allow heap pages with tuple headers < VACUUM's
> OldestXmin to be created, which are overlooked by that same VACUUM
> (they're beyond the same VACUUM's rel_pages). As a result of all this,
> VACUUM might advance pg_class.relfrozenxid to a later/younger value
> than a remaining/unfrozen XID value from one of these unscanned heap
> pages.

Thanks for the report. That was a dumb mistake. There was no reason
for me to move the line up as you can see in the diff -- it must have
been unintentional. I'll push the fix tomorrow.

I started to feel like I ought to write a TAP test, but I'm hesitant
to add a whole new TAP test for a case when a comment should have been
sufficient deterrent.

- Melanie

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Geoghegan 2025-06-01 18:22:38 Re: RelationGetNumberOfBlocks called before vacuum_get_cutoffs
Previous Message Jiří Kavalík 2025-06-01 16:58:05 [PATCH] Support for basic ALTER TABLE progress reporting.