Обсуждение: pgsql: Revamp the WAL record format.

Поиск
Список
Период
Сортировка

pgsql: Revamp the WAL record format.

От
Heikki Linnakangas
Дата:
Revamp the WAL record format.

Each WAL record now carries information about the modified relation and
block(s) in a standardized format. That makes it easier to write tools that
need that information, like pg_rewind, prefetching the blocks to speed up
recovery, etc.

There's a whole new API for building WAL records, replacing the XLogRecData
chains used previously. The new API consists of XLogRegister* functions,
which are called for each buffer and chunk of data that is added to the
record. The new API also gives more control over when a full-page image is
written, by passing flags to the XLogRegisterBuffer function.

This also simplifies the XLogReadBufferForRedo() calls. The function can dig
the relation and block number from the WAL record, so they no longer need to
be passed as arguments.

For the convenience of redo routines, XLogReader now disects each WAL record
after reading it, copying the main data part and the per-block data into
MAXALIGNed buffers. The data chunks are not aligned within the WAL record,
but the redo routines can assume that the pointers returned by XLogRecGet*
functions are. Redo routines are now passed the XLogReaderState, which
contains the record in the already-disected format, instead of the plain
XLogRecord.

The new record format also makes the fixed size XLogRecord header smaller,
by removing the xl_len field. The length of the "main data" portion is now
stored at the end of the WAL record, and there's a separate header after
XLogRecord for it. The alignment padding at the end of XLogRecord is also
removed. This compansates for the fact that the new format would otherwise
be more bulky than the old format.

Reviewed by Andres Freund, Amit Kapila, Michael Paquier, Alvaro Herrera,
Fujii Masao.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/2c03216d831160bedd72d45f712601b6f7d03f1c

Modified Files
--------------
contrib/pg_xlogdump/pg_xlogdump.c               |  128 +--
contrib/pg_xlogdump/rmgrdesc.h                  |    2 +-
src/backend/access/brin/brin.c                  |   11 +-
src/backend/access/brin/brin_pageops.c          |   97 +--
src/backend/access/brin/brin_revmap.c           |   23 +-
src/backend/access/brin/brin_xlog.c             |  111 ++-
src/backend/access/gin/ginbtree.c               |  111 +--
src/backend/access/gin/gindatapage.c            |  162 ++--
src/backend/access/gin/ginentrypage.c           |   64 +-
src/backend/access/gin/ginfast.c                |   92 +--
src/backend/access/gin/gininsert.c              |   10 +-
src/backend/access/gin/ginutil.c                |   10 +-
src/backend/access/gin/ginvacuum.c              |  114 +--
src/backend/access/gin/ginxlog.c                |  341 +++-----
src/backend/access/gist/gist.c                  |    9 +
src/backend/access/gist/gistbuild.c             |    9 +-
src/backend/access/gist/gistxlog.c              |  269 +++---
src/backend/access/hash/hash.c                  |    2 +-
src/backend/access/heap/heapam.c                |  987 ++++++++++-------------
src/backend/access/heap/rewriteheap.c           |   19 +-
src/backend/access/nbtree/nbtinsert.c           |  207 ++---
src/backend/access/nbtree/nbtpage.c             |  175 ++--
src/backend/access/nbtree/nbtxlog.c             |  353 ++++----
src/backend/access/rmgrdesc/brindesc.c          |   41 +-
src/backend/access/rmgrdesc/clogdesc.c          |    4 +-
src/backend/access/rmgrdesc/dbasedesc.c         |    4 +-
src/backend/access/rmgrdesc/gindesc.c           |   40 +-
src/backend/access/rmgrdesc/gistdesc.c          |   23 +-
src/backend/access/rmgrdesc/hashdesc.c          |    2 +-
src/backend/access/rmgrdesc/heapdesc.c          |   72 +-
src/backend/access/rmgrdesc/mxactdesc.c         |    4 +-
src/backend/access/rmgrdesc/nbtdesc.c           |   52 +-
src/backend/access/rmgrdesc/relmapdesc.c        |    4 +-
src/backend/access/rmgrdesc/seqdesc.c           |    4 +-
src/backend/access/rmgrdesc/smgrdesc.c          |    4 +-
src/backend/access/rmgrdesc/spgdesc.c           |   74 +-
src/backend/access/rmgrdesc/standbydesc.c       |    4 +-
src/backend/access/rmgrdesc/tblspcdesc.c        |    4 +-
src/backend/access/rmgrdesc/xactdesc.c          |    4 +-
src/backend/access/rmgrdesc/xlogdesc.c          |   10 +-
src/backend/access/spgist/spgdoinsert.c         |  243 +++---
src/backend/access/spgist/spginsert.c           |   17 +-
src/backend/access/spgist/spgvacuum.c           |   72 +-
src/backend/access/spgist/spgxlog.c             |  335 ++++----
src/backend/access/transam/README               |  249 +++---
src/backend/access/transam/clog.c               |   25 +-
src/backend/access/transam/multixact.c          |   33 +-
src/backend/access/transam/twophase.c           |  105 +--
src/backend/access/transam/xact.c               |  129 ++-
src/backend/access/transam/xlog.c               |  348 ++++----
src/backend/access/transam/xloginsert.c         |  972 ++++++++++++++--------
src/backend/access/transam/xlogreader.c         |  486 ++++++++---
src/backend/access/transam/xlogutils.c          |  237 ++----
src/backend/catalog/storage.c                   |   31 +-
src/backend/commands/dbcommands.c               |   46 +-
src/backend/commands/sequence.c                 |   77 +-
src/backend/commands/tablespace.c               |   31 +-
src/backend/replication/logical/decode.c        |  158 ++--
src/backend/replication/logical/logical.c       |    7 +-
src/backend/replication/logical/logicalfuncs.c  |    4 +-
src/backend/replication/logical/reorderbuffer.c |    1 +
src/backend/replication/logical/snapbuild.c     |    2 +-
src/backend/replication/walsender.c             |    2 +-
src/backend/storage/ipc/standby.c               |   41 +-
src/backend/utils/cache/relmapper.c             |   20 +-
src/bin/pg_resetxlog/pg_resetxlog.c             |   14 +-
src/include/access/brin_xlog.h                  |   63 +-
src/include/access/clog.h                       |    6 +-
src/include/access/gin.h                        |    6 +-
src/include/access/gin_private.h                |   66 +-
src/include/access/gist_private.h               |   31 +-
src/include/access/hash.h                       |    6 +-
src/include/access/heapam_xlog.h                |  139 ++--
src/include/access/htup_details.h               |    1 +
src/include/access/itup.h                       |    1 +
src/include/access/multixact.h                  |    6 +-
src/include/access/nbtree.h                     |   94 +--
src/include/access/spgist.h                     |    6 +-
src/include/access/spgist_private.h             |  144 ++--
src/include/access/xact.h                       |    6 +-
src/include/access/xlog.h                       |   10 +-
src/include/access/xlog_internal.h              |   19 +-
src/include/access/xloginsert.h                 |   70 +-
src/include/access/xlogreader.h                 |   77 +-
src/include/access/xlogrecord.h                 |  160 +++-
src/include/access/xlogutils.h                  |   21 +-
src/include/catalog/storage_xlog.h              |    6 +-
src/include/commands/dbcommands.h               |    6 +-
src/include/commands/sequence.h                 |    6 +-
src/include/commands/tablespace.h               |    6 +-
src/include/replication/decode.h                |    2 +-
src/include/storage/standby.h                   |    6 +-
src/include/utils/relmapper.h                   |    6 +-
93 files changed, 3945 insertions(+), 4366 deletions(-)


Re: pgsql: Revamp the WAL record format.

От
Tom Lane
Дата:
Heikki Linnakangas <heikki.linnakangas@iki.fi> writes:
> Revamp the WAL record format.

My version of gcc bitches about this:

nbtxlog.c: In function 'btree_xlog_split':
nbtxlog.c:272: warning: 'newitem' may be used uninitialized in this function
nbtxlog.c:272: note: 'newitem' was declared here

            regards, tom lane


Re: pgsql: Revamp the WAL record format.

От
Heikki Linnakangas
Дата:
On 11/20/2014 07:12 PM, Tom Lane wrote:
> Heikki Linnakangas <heikki.linnakangas@iki.fi> writes:
>> Revamp the WAL record format.
>
> My version of gcc bitches about this:
>
> nbtxlog.c: In function 'btree_xlog_split':
> nbtxlog.c:272: warning: 'newitem' may be used uninitialized in this function
> nbtxlog.c:272: note: 'newitem' was declared here

Fixed, thanks!

- Heikki