Re: eliminate xl_heap_visible to reduce WAL (and eventually set VM on-access)

From: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
To: Melanie Plageman <melanieplageman(at)gmail(dot)com>
Cc: Alexander Lakhin <exclusion(at)gmail(dot)com>, Andres Freund <andres(at)anarazel(dot)de>, Tomas Vondra <tomas(at)vondra(dot)me>, David Rowley <dgrowleyml(at)gmail(dot)com>, Kirill Reshke <reshkekirill(at)gmail(dot)com>, Andrey Borodin <x4mmm(at)yandex-team(dot)ru>, Xuneng Zhou <xunengzhou(at)gmail(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
Subject: Re: eliminate xl_heap_visible to reduce WAL (and eventually set VM on-access)
Date: 2026-09-11 03:02:29
Message-ID: B46378A3-A332-43BE-B648-058B86858BAD@gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> On Sep 11, 2026, at 02:31, Melanie Plageman <melanieplageman(at)gmail(dot)com> wrote:
>
> On Tue, Apr 21, 2026 at 5:37 PM Melanie Plageman
> <melanieplageman(at)gmail(dot)com> wrote:
>>
>> On Mon, Apr 20, 2026 at 12:18 PM Melanie Plageman
>> <melanieplageman(at)gmail(dot)com> wrote:
>>>
>>>
>>> Yes, I think changing it to a temp table is the easiest fix. We could
>>> also do autovacuum_enabled=false, I think, but making it a temp table
>>> seems cleanest.
>>>
>>> I wonder if we should move the EXPLAIN test above the results queries,
>>> then throw in a vacuum in between some of them so we exercise btree
>>> gist as a bitmap heap scan and as an index only scan. It could provide
>>> a little bit more coverage? Or maybe that isn't actually extra
>>> coverage. I'm not sure.
>>
>> I kept it simple and just committed making it a temp table in 62407d26b7c
>
> An adversarial LLM review of this patch series found that I call
> visibilitymap_pin() after taking a cleanup lock on the heap page in
> the on-access pruning path -- which is not good. Here is a small patch
> to fix that. Doing it before we're sure we can get the cleanup lock
> could occasionally lead to an unneeded pin, but such situations should
> be uncommon.
>
> - Melanie
> <v1-0001-Make-on-access-pruning-pin-visibility-map-before-.patch>

Looks reasonable to me to move visibilitymap_pin to before ConditionalLockBufferForCleanup. I saw the header comment of of visibilitymap_pin explicitly says that "Because that can require I/O to read the map page, you shouldn't hold a lock on the heap page while doing that.”.

I was thinking if we should unpin when ConditionalLockBufferForCleanup fails, but the new comment seems to resolve my confusion, because next heap page may map the same VM page.

So v1 LGTM.

Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message shveta malik 2026-09-11 03:19:09 Re: Review items for EXCEPT TABLE publication
Previous Message chee.wooson 2026-09-11 02:51:30 Re: Recovery conflict resolution misses backends that import snapshots