Re: Be strict when request to flush past end of WAL in WaitXLogInsertionsToFinish

From: Paul Kim <mok03127(at)gmail(dot)com>
To: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Be strict when request to flush past end of WAL in WaitXLogInsertionsToFinish
Date: 2026-09-16 12:26:22
Message-ID: 178956158235.97809.18200289969141907831@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

The cfbot's Linux 32-bit task failed on v3: the TAP test's padding
loop raised "could not align the insert position". The loop computed
the exact-fill payload as (gap - base), with base measured from a
message with an empty payload. Once the payload exceeds the short
data header's range, the record switches to the long data header,
which is 3 bytes larger. With 8-byte MAXALIGN those extra bytes
disappear into alignment padding and the fill still lands exactly on
the target, but with 4-byte MAXALIGN they round up to a 4-byte
overshoot, so on 32-bit builds every attempt missed the window and the
loop gave up.

Here is v4, which approaches the target in small steps once the gap
falls below base + 200 bytes, so the final exact-fill record always
keeps the short data header. While at it, the window-hit check no
longer hardcodes SizeOfXLogLongPHD as 40 bytes (36 on 32-bit): a
normal switch reports the segment boundary itself and only the
overridden EndPos lies past it, so any nonzero offset into the new
segment marks the hit.

No changes to the fix; 0001 is identical to v3.

Regards,
Paul Kim

Attachment Content-Type Size
v4-0001-Honor-the-WAL-insertion-adjustment-in-XLogBackgro.patch text/x-patch 3.6 KB
v4-0002-Add-a-TAP-test-for-the-WAL-insertion-adjustment-i.patch text/x-patch 7.3 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Previous Message Shinya Kato 2026-09-16 12:14:35 Re: Add TOAST statistics columns to pg_stat_all_tables