Refactor WAL file-reading code into WALRead()
Alvaro Herrera <alvherre@alvh.no-ip.org>
Refactor WAL file-reading code into WALRead() XLogReader, walsender and pg_waldump all had their own routines to read data from WAL files to memory, with slightly different approaches according to the particular conditions of each environment. There's a lot of commonality, so we can refactor that into a single routine WALRead in XLogReader, and move the differences to a separate (simpler) callback that just opens the next WAL-segment. This results in a clearer (ahem) code flow. The error reporting needs are covered by filling in a new error-info struct, WALReadError, and it's the caller's responsibility to act on it. The backend has WALReadRaiseError() to do so. We no longer ever need to seek in this interface; switch to using pg_pread(). Author: Antonin Houska, with contributions from Álvaro Herrera Reviewed-by: Michaël Paquier, Kyotaro Horiguchi Discussion: https://postgr.es/m/14984.1554998742@spoje.net
Files
| Path | Change | +/− |
|---|---|---|
| src/backend/access/transam/xlogreader.c | modified | +100 −6 |
| src/backend/access/transam/xlogutils.c | modified | +71 −134 |
| src/backend/replication/walsender.c | modified | +123 −177 |
| src/bin/pg_waldump/pg_waldump.c | modified | +53 −115 |
| src/include/access/xlogreader.h | modified | +38 −1 |
| src/include/access/xlogutils.h | modified | +2 −0 |
Discussion
- Attempt to consolidate reading of XLOG page 62 messages · 2019-04-11 → 2020-03-17