Hi Sehrope,

Thank you for the detailed review!

On Sat, Sep 5, 2026, Sehrope Sarkuni wrote:
> I think this needs an opt-in from the client. Something like a
> START_REPLICATION option or at least a protocol guard.

I agree.  v2 adds a SKIP_WAL_PADDING option to physical
START_REPLICATION.  Existing clients continue to receive ordinary WALData
messages, and built-in clients request the new format only from PG20 servers.

The receiver no longer truncates and extends the segment.  A segment newly
created by walreceiver is already zero-filled according to wal_init_zero. For
an existing or recycled segment, walreceiver writes the zeros locally with
the normal wait-event and pg_stat_io accounting.  This also removes the
short-file crash window.  New uncompressed pg_receivewal output is already
pre-padded.  Resumed, compressed, and tar output generate the zeros locally.

I also added the missing Meson registration and used
pg_memory_is_all_zeros().  As a compatibility check, I connected a pre-patch
PG20 pg_receivewal to the patched server and compared the resulting switched
segment byte for byte.

PFA v2.  Thank you!


Best regards, Andrey Borodin.

Attachment: v2-0001-Avoid-streaming-zero-filled-WAL-switch-padding.patch
Description: Binary data

Reply via email to