postgresql/src/backend/access/rmgrdesc
Heikki Linnakangas f83d709760 Merge prune, freeze and vacuum WAL record formats
The new combined WAL record is now used for pruning, freezing and 2nd
pass of vacuum. This is in preparation for changing VACUUM to write a
combined prune+freeze record per page, instead of separate two
records. The new WAL record format now supports that, but the code
still always writes separate records for pruning and freezing.

This reserves separate XLOG_HEAP2_* info codes for when the pruning
record is emitted for on-access pruning or VACUUM, per Peter
Geoghegan's suggestion. The record format is identical, but having
separate info codes makes it easier analyze pruning and vacuuming with
pg_waldump.

The function to emit the new WAL record, log_heap_prune_and_freeze(),
is in pruneheap.c. The existing heap_log_freeze_plan() and its
subroutines are moved to pruneheap.c without changes, to keep them
together with log_heap_prune_and_freeze().

Author: Melanie Plageman <melanieplageman@gmail.com>
Discussion: https://www.postgresql.org/message-id/CAAKRu_azf-zH%3DDgVbquZ3tFWjMY1w5pO8m-TXJaMdri8z3933g@mail.gmail.com
Discussion: https://www.postgresql.org/message-id/CAAKRu_b2oE4GL%3Dq4g9mcByS9yT7wTQvEH9OLpabj28e%2BWKFi2A@mail.gmail.com
2024-03-25 14:59:58 +02:00
..
Makefile Show more detail in heapam rmgr descriptions. 2023-04-07 16:08:52 -07:00
README Add rmgrdesc README 2023-10-02 12:18:57 +03:00
brindesc.c Update copyright for 2024 2024-01-03 20:49:05 -05:00
clogdesc.c Update copyright for 2024 2024-01-03 20:49:05 -05:00
committsdesc.c Remove unused #include's from backend .c files 2024-03-04 12:02:20 +01:00
dbasedesc.c Update copyright for 2024 2024-01-03 20:49:05 -05:00
genericdesc.c Remove unused #include's from backend .c files 2024-03-04 12:02:20 +01:00
gindesc.c Remove unused #include's from backend .c files 2024-03-04 12:02:20 +01:00
gistdesc.c Remove unused #include's from backend .c files 2024-03-04 12:02:20 +01:00
hashdesc.c Update copyright for 2024 2024-01-03 20:49:05 -05:00
heapdesc.c Merge prune, freeze and vacuum WAL record formats 2024-03-25 14:59:58 +02:00
logicalmsgdesc.c Update copyright for 2024 2024-01-03 20:49:05 -05:00
meson.build Update copyright for 2024 2024-01-03 20:49:05 -05:00
mxactdesc.c Update copyright for 2024 2024-01-03 20:49:05 -05:00
nbtdesc.c Update copyright for 2024 2024-01-03 20:49:05 -05:00
relmapdesc.c Update copyright for 2024 2024-01-03 20:49:05 -05:00
replorigindesc.c Update copyright for 2024 2024-01-03 20:49:05 -05:00
rmgrdesc_utils.c Update copyright for 2024 2024-01-03 20:49:05 -05:00
seqdesc.c Update copyright for 2024 2024-01-03 20:49:05 -05:00
smgrdesc.c Update copyright for 2024 2024-01-03 20:49:05 -05:00
spgdesc.c Update copyright for 2024 2024-01-03 20:49:05 -05:00
standbydesc.c Update copyright for 2024 2024-01-03 20:49:05 -05:00
tblspcdesc.c Update copyright for 2024 2024-01-03 20:49:05 -05:00
xactdesc.c Update copyright for 2024 2024-01-03 20:49:05 -05:00
xlogdesc.c Update copyright for 2024 2024-01-03 20:49:05 -05:00

README

src/backend/access/rmgrdesc/README

WAL resource manager description functions
==========================================

For debugging purposes, there is a "description function", or rmgrdesc
function, for each WAL resource manager. The rmgrdesc function parses the WAL
record and prints the contents of the WAL record in a somewhat human-readable
format.

The rmgrdesc functions for all resource managers are gathered in this
directory, because they are also used in the stand-alone pg_waldump program.
They could potentially be used by out-of-tree debugging tools too, although
neither the description functions nor the output format should be considered
part of a stable API

Guidelines for rmgrdesc output format
-------------------------------------

The goal of these guidelines is to avoid gratuitous inconsistencies across
each rmgr, and to allow users to parse desc output strings without too much
difficulty.  This is not an API specification or an interchange format.
(Only heapam and nbtree desc routines follow these guidelines at present, in
any case.)

Record descriptions are similar to JSON style key/value objects.  However,
there is no explicit "string" type/string escaping.  Top-level { } brackets
should be omitted.  For example:

snapshotConflictHorizon: 0, flags: 0x03

Record descriptions may contain variable-length arrays.  For example:

nunused: 5, unused: [1, 2, 3, 4, 5]

Nested objects are supported via { } brackets.  They generally appear inside
variable-length arrays.  For example:

ndeleted: 0, nupdated: 1, deleted: [], updated: [{ off: 45, nptids: 1, ptids: [0] }]

Try to output things in an order that faithfully represents the order of
fields from the underlying physical WAL record struct.  Key names should be
unique (at the same nesting level) to make parsing easy.  It's a good idea if
the number of items in the array appears before the array.

It's okay for individual WAL record types to invent their own conventions.
For example, Heap2's PRUNE record descriptions use a custom array format for
the record's "redirected" field:

... redirected: [1->4, 5->9], dead: [10, 11], unused: [3, 7, 8]

Arguably the desc routine should be using object notation for this instead.
However, there is value in using a custom format when it conveys useful
information about the underlying physical data structures.

This ad-hoc format has the advantage of being close to the format used for
the "dead" and "unused" arrays (which follow the standard desc convention for
page offset number arrays).  It suggests that the "redirected" elements shown
are just pairs of page offset numbers (which is how it really works).

rmgrdesc_utils.c contains some helper functions to print data in this format.