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-14 23:59:26
Message-ID: 178943036660.93390.9276321783121497682@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Here is v3, with the changes discussed upthread:

- s/clamp/adjust/ in the comments and commit messages.

- XLogBackgroundFlush() now has a comment explaining why the adjusted
position is applied conditionally instead of being assigned the way
XLogFlush() does.

- The C injector module is gone. The TAP test now reproduces the
incident naturally: it pads WAL with pg_logical_emit_message() until
the insert position is exactly SizeOfXLogRecord bytes before a
segment boundary and then calls pg_switch_wal(), as described in my
previous mail. Since no dedicated module is needed anymore, the
test moved to src/test/modules/test_misc. If a concurrent record
(e.g. a bgwriter snapshot) spoils the alignment, the test retries on
a later segment boundary; pg_switch_wal()'s return value tells
whether the window was hit.

On an unpatched assert build the test brings the walwriter down with
Assert("Insert >= Write") and fails; with the fix it passes. The fix
itself is unchanged from v2 apart from comments. Rebased onto current
master.

Regards,
Paul Kim

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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Toshiki Toda 2026-09-15 00:02:34 Re: Add TOAST statistics columns to pg_stat_all_tables
Previous Message Jacob Champion 2026-09-14 23:55:47 Re: [PATCH] Explain what the default output_plugin_libraries do