pgsql: Add circular WAL decoding buffer, take II.

From: Thomas Munro <tmunro(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Add circular WAL decoding buffer, take II.
Date: 2022-03-18 05:49:10
Message-ID: E1nV5U6-000EF7-6r@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Add circular WAL decoding buffer, take II.

Teach xlogreader.c to decode the WAL into a circular buffer. This will
support optimizations based on looking ahead, to follow in a later
commit.

* XLogReadRecord() works as before, decoding records one by one, and
allowing them to be examined via the traditional XLogRecGetXXX()
macros and certain traditional members like xlogreader->ReadRecPtr.

* An alternative new interface XLogReadAhead()/XLogNextRecord() is
added that returns pointers to DecodedXLogRecord objects so that it's
now possible to look ahead in the WAL stream while replaying.

* In order to be able to use the new interface effectively while
streaming data, support is added for the page_read() callback to
respond to a new nonblocking mode with XLREAD_WOULDBLOCK instead of
waiting for more data to arrive.

No direct user of the new interface is included in this commit, though
XLogReadRecord() uses it internally. Existing code doesn't need to
change, except in a few places where it was accessing reader internals
directly and now needs to go through accessor macros.

Reviewed-by: Julien Rouhaud <rjuju123(at)gmail(dot)com>
Reviewed-by: Tomas Vondra <tomas(dot)vondra(at)enterprisedb(dot)com>
Reviewed-by: Andres Freund <andres(at)anarazel(dot)de> (earlier versions)
Discussion: https://postgr.es/m/CA+hUKGJ4VJN8ttxScUFM8dOKX0BrBiboo5uz1cq=AovOddfHpA@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/3f1ce973467a0d285961bf2f99b11d06e264e2c1

Modified Files
--------------
src/backend/access/transam/generic_xlog.c | 6 +-
src/backend/access/transam/xlog.c | 18 +-
src/backend/access/transam/xlogreader.c | 645 ++++++++++++++++++++++++------
src/backend/access/transam/xlogrecovery.c | 4 +-
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 | 25 +-
src/include/access/xlogreader.h | 154 +++++--
src/tools/pgindent/typedefs.list | 2 +
10 files changed, 686 insertions(+), 174 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Amit Kapila 2022-03-18 05:57:03 Re: pgsql: Fix row filters with multiple publications
Previous Message Thomas Munro 2022-03-18 05:15:47 Re: pgsql: Add option to use ICU as global locale provider