From: Thomas Munro <tmunro@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Add circular WAL decoding buffer.
Date: Thu, 08 Apr 2021 11:23:10 +0000
Message-ID: <E1lUSkg-0007xK-CZ@gemulon.postgresql.org> (raw)
Add circular WAL decoding buffer.
Teach xlogreader.c to decode its output into a circular buffer, to
support optimizations based on looking ahead.
* XLogReadRecord() works as before, consuming records one by one, and
allowing them to be examined via the traditional XLogRecGetXXX()
macros.
* An alternative new interface XLogNextRecord() is added that returns
pointers to DecodedXLogRecord structs that can be examined directly.
* XLogReadAhead() provides a second cursor that lets you see
further ahead, as long as data is available and there is enough space
in the decoding buffer. This returns DecodedXLogRecord pointers to the
caller, but also adds them to a queue of records that will later be
consumed by XLogNextRecord()/XLogReadRecord().
The buffer's size is controlled with wal_decode_buffer_size. The buffer
could potentially be placed into shared memory, for future projects.
Large records that don't fit in the circular buffer are called
"oversized" and allocated separately with palloc().
Discussion: https://postgr.es/m/CA+hUKGJ4VJN8ttxScUFM8dOKX0BrBiboo5uz1cq=AovOddfHpA@mail.gmail.com
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/f003d9f8721b3249e4aec8a1946034579d40d42c
Modified Files
--------------
src/backend/access/transam/generic_xlog.c | 6 +-
src/backend/access/transam/xlog.c | 28 +-
src/backend/access/transam/xlogreader.c | 744 ++++++++++++++++++++++++------
src/backend/access/transam/xlogutils.c | 2 +-
src/backend/replication/logical/decode.c | 2 +-
src/bin/pg_rewind/parsexlog.c | 2 +-
src/bin/pg_waldump/pg_waldump.c | 22 +-
src/include/access/xlogreader.h | 128 +++--
8 files changed, 734 insertions(+), 200 deletions(-)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-committers@postgresql.org
Cc: tmunro@postgresql.org
Subject: Re: pgsql: Add circular WAL decoding buffer.
In-Reply-To: <E1lUSkg-0007xK-CZ@gemulon.postgresql.org>
References: <E1lUSkg-0007xK-CZ@gemulon.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox