Re: Compression of bigger WAL records

From: Andrey Borodin <x4mmm(at)yandex-team(dot)ru>
To: Michael Paquier <michael(at)paquier(dot)xyz>
Cc: Japin Li <japinli(at)hotmail(dot)com>, Fujii Masao <masao(dot)fujii(at)gmail(dot)com>, wenhui qiu <qiuwenhuifx(at)gmail(dot)com>, Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Compression of bigger WAL records
Date: 2026-10-06 13:09:38
Message-ID: B2902A9C-6BFA-493B-8FE9-A3A733DB1CA3@yandex-team.ru
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Michael!

Thanks for looking into this!

Attached v10 contains only the context-reuse changes, split into replay
(0001) and WAL insertion (0002).

The reader now owns a ZSTD_DCtx pointer under USE_ZSTD. Backend builds
register a reset callback in the reader's memory context, and
XLogReaderFree() unregisters it before freeing the context. I also
shortened the compression-side comment.

We could also avoid this cleanup bookkeeping with a static context, as
in 0002. For now we only decompress independent images in one call, with
no history to preserve between records.

On 6 Oct 2026, at 03:34 UTC, Michael Paquier wrote:
> The replay part makes the good choice, so I'm puzzled as of why you
> have chosen a safe failure mode here.

My reasoning was that the writer can still store an uncompressed image,
whereas replay cannot restore a compressed image without the context.
I changed this as you suggested, but I still think falling back to an
uncompressed image is preferable. We are in a critical section.

wal_compression can change during a session, so preparing the workspace
outside critical sections is not straightforward. This is also the
hardest and most contentious part of the whole-record and streaming
compression patches. I'm trying to reuse the FPI compression buffers,
but still need twice as much buffer space as before. I haven't found a
better approach. Your thoughts on the allocation strategy would be very
helpful, even without reviewing those patches.

Thank you!

Best regards, Andrey Borodin.

Attachment Content-Type Size
v10-0001-Reuse-zstd-decompression-contexts-when-restoring.patch application/octet-stream 4.5 KB
v10-0002-Reuse-the-zstd-context-when-compressing-WAL-imag.patch application/octet-stream 2.2 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Jakub Wartak 2026-10-06 13:10:38 Re: enhancing pg_basebackup speeds up to ~23Gbps (small fixes + io_uring/Direct I/O)
Previous Message Vaibhav Dalvi 2026-10-06 12:30:38 Re: remote_apply commit hangs when wal_receiver_status_interval = 0