Re: Bug in MultiXact replay compat logic for older minor version after crash-recovery - Mailing list pgsql-hackers

From Heikki Linnakangas
Subject Re: Bug in MultiXact replay compat logic for older minor version after crash-recovery
Date
Msg-id 452355ef-7c20-4d96-88a2-8fbb49737dc9@iki.fi
Whole thread Raw
In response to Re: Bug in MultiXact replay compat logic for older minor version after crash-recovery  (Andrey Borodin <x4mmm@yandex-team.ru>)
Responses Re: Bug in MultiXact replay compat logic for older minor version after crash-recovery
List pgsql-hackers
On 20/03/2026 13:55, Andrey Borodin wrote:
>> On 19 Mar 2026, at 23:11, Heikki Linnakangas <hlinnaka@iki.fi> wrote:
>> I think a better fix is to accept that our tracking is a little
>> imprecise and use SimpleLruDoesPhysicalPageExist() to check if the
>> page exists. I suspect that's too expensive to do on every
>> RecordNewMultiXact() call that crosses a page, but perhaps we
>> could do it once at StartupMultiXact().
>> 
>> Or perhaps track last-zeroed page separately from
>> latest_page_number, and if we haven't seen any
>> XLOG_MULTIXACT_ZERO_OFF_PAGE records yet after startup, call
>> SimpleLruDoesPhysicalPageExist() to determine if initialization is
>> needed. Attached patch does that.
> 
> SimpleLruDoesPhysicalPageExist() does not detect recently zeroed
> pages via buffers, because it goes directly to FS. I tried this
> approach when implementing deadlock fix, it did not work for me.

Hmm, after startup, before we have zeroed any pages, it still works 
though. So I think my patch works, but it means that tracking the latest 
page we have zeroed is not merely an optimization to avoid excessive 
SimpleLruDoesPhysicalPageExist() calls, it's needed for correctness. 
Need to adjust the comments for that.

- Heikki



pgsql-hackers by date:

Previous
From: Álvaro Herrera
Date:
Subject: Re: Resetting snapshots during the first phase of [CREATE |RE]INDEX CONCURRENTLY
Next
From: Amul Sul
Date:
Subject: Re: pg_waldump: support decoding of WAL inside tarfile