Re: Use WALReadFromBuffers in more places
Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
From: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
To: Jingtang Zhang <mrdrivingduck@gmail.com>
Cc: pgsql-hackers@lists.postgresql.org, Nitin Jadhav <nitinjadhavpostgres@gmail.com>
Date: 2025-09-14T05:04:58Z
Lists: pgsql-hackers
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Read WAL directly from WAL buffers.
- 91f2cae7a4e6 17.0 cited
Attachments
- v3-0001-Use-WALReadFromBuffers-in-more-places.patch (application/octet-stream) patch v3-0001
Hi, On Tue, Oct 15, 2024 at 1:22 AM Jingtang Zhang <mrdrivingduck@gmail.com> wrote: > > I've been back to this patch for a while recently. I witness that if a WAL > writer works fast, the already flushed WAL buffers will be zeroed out and > re-initialized for future use by AdvanceXLInsertBuffer in > XLogBackgroundFlush, so that WALReadFromBuffers will miss even though the > space of WAL buffer is enough. It is much more unfriendly for logical > walsenders than physical walsenders, because logical ones consume WAL > slower than physical ones due to the extra decoding phase. Seems that the aim > of AdvanceXLInsertBuffer in WAL writer contradicts with our reading from > WAL buffer. Any thoughts? Thanks for looking at this. Yes, the WAL writers can zero out flushed buffers before WALReadFromBuffers gets to them. However, WALReadFromBuffers was intentionally designed as an opportunistic optimization - it's a "try this first, quickly" approach before falling back to reading from WAL files. The no-locks design ensures it never gets in the way of backends generating WAL, which is critical for overall system performance. I rebased and attached the v3 patch. I discarded the test extension patch that demonstrated WALReadFromBuffers' behavior (i.e., waiting for WAL to be fully copied to WAL buffers with WaitXLogInsertionsToFinish), as I believe the comment at the top of WALReadFromBuffers is sufficient documentation. I can reintroduce the test extension if there's interest. Thoughts? -- Bharath Rupireddy PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com