Re: Avoid streaming zero-filled WAL switch padding

From: Andrey Borodin <x4mmm(at)yandex-team(dot)ru>
To: Sehrope Sarkuni <sehrope(at)jackdb(dot)com>
Cc: pgsql-hackers mailing list <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Avoid streaming zero-filled WAL switch padding
Date: 2026-09-06 12:49:45
Message-ID: 52B75676-BAB2-42BC-8D20-EB3FA0C7439A@yandex-team.ru
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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 Content-Type Size
v2-0001-Avoid-streaming-zero-filled-WAL-switch-padding.patch application/octet-stream 32.5 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Zsolt Parragi 2026-09-06 13:10:14 Re: Add TG_* vars for FOR PORTION OF
Previous Message Andrey Borodin 2026-09-06 12:27:44 Re: Protocol compression: a fourth design