Re: Allow aggressive VACUUM to freeze without a cleanup lock

From: Peter Geoghegan <pg(at)bowt(dot)ie>
To: Melanie Plageman <melanieplageman(at)gmail(dot)com>
Cc: Jingtang Zhang <mrdrivingduck(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Allow aggressive VACUUM to freeze without a cleanup lock
Date: 2026-08-25 14:47:11
Message-ID: CAH2-WzmP-g23iCemuQ=O0w_fvbyQps-rRjdBkkAmhBxOARSrXA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Aug 25, 2026 at 10:28 AM Peter Geoghegan <pg(at)bowt(dot)ie> wrote:
> As far as I know, the only fundamental reason we require a cleanup
> lock is to make page defragmentation safe. Pruning as currently
> defined implies page defragmentation, and freezing is closely tied to
> pruning, so we tend to treat both as requiring a cleanup lock. But a
> cleanup lock is likely not strictly necessary.

Fun fact: prior to the invention of HOT in 2007, we'd freeze with only
a *shared* lock in the first heap pass. The first heap pass collected
dead TIDs and performed freezing, but it didn't do any pruning.
Freezing wasn't tied to pruning (or anything like it) in the way it is
today.

Pruning didn't really exist (not as we know it today), but page
defragmentation did. At that time, we only removed dead tuples/tuple
storage and performed page defragmentation in VACUUM's second heap
pass (which required a full cleanup lock).

So it's reasonable to surmise that freezing could be done with only an
exclusive lock on top of the current VACUUM code (though not a shared
lock, which seems really dangerous). And that page defragmentation is
the only thing that necessitates a cleanup lock/makes this idea
difficult.

--
Peter Geoghegan

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Jan Nidzwetzki 2026-08-25 14:50:09 Re: Enable partitionwise join for partition keys wrapped by RelabelType
Previous Message Nathan Bossart 2026-08-25 14:30:18 Re: add list of major features to the v19 release notes