aboutsummaryrefslogtreecommitdiff
path: root/src/backend/access/transam/generic_xlog.c
diff options
context:
space:
mode:
authorThomas Munro <tmunro@postgresql.org>2021-04-08 23:03:34 +1200
committerThomas Munro <tmunro@postgresql.org>2021-04-08 23:20:42 +1200
commitf003d9f8721b3249e4aec8a1946034579d40d42c (patch)
treef53cd4a664fc1212156d32cd6f7dd6da507e0602 /src/backend/access/transam/generic_xlog.c
parent323cbe7c7ddcf18aaf24b7f6d682a45a61d4e31b (diff)
downloadpostgresql-f003d9f8721b3249e4aec8a1946034579d40d42c.tar.gz
postgresql-f003d9f8721b3249e4aec8a1946034579d40d42c.zip
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
Diffstat (limited to 'src/backend/access/transam/generic_xlog.c')
-rw-r--r--src/backend/access/transam/generic_xlog.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/backend/access/transam/generic_xlog.c b/src/backend/access/transam/generic_xlog.c
index 63301a1ab16..0e9bcc71596 100644
--- a/src/backend/access/transam/generic_xlog.c
+++ b/src/backend/access/transam/generic_xlog.c
@@ -482,10 +482,10 @@ generic_redo(XLogReaderState *record)
uint8 block_id;
/* Protect limited size of buffers[] array */
- Assert(record->max_block_id < MAX_GENERIC_XLOG_PAGES);
+ Assert(XLogRecMaxBlockId(record) < MAX_GENERIC_XLOG_PAGES);
/* Iterate over blocks */
- for (block_id = 0; block_id <= record->max_block_id; block_id++)
+ for (block_id = 0; block_id <= XLogRecMaxBlockId(record); block_id++)
{
XLogRedoAction action;
@@ -525,7 +525,7 @@ generic_redo(XLogReaderState *record)
}
/* Changes are done: unlock and release all buffers */
- for (block_id = 0; block_id <= record->max_block_id; block_id++)
+ for (block_id = 0; block_id <= XLogRecMaxBlockId(record); block_id++)
{
if (BufferIsValid(buffers[block_id]))
UnlockReleaseBuffer(buffers[block_id]);