1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-31 22:04:40 +03:00

pg_waldump: Add --save-fullpage=PATH to save full page images from WAL records

This option extracts (potentially decompressing) full-page images
included in WAL records into a given target directory.  These images are
subject to the same filtering rules as the normal display of the WAL
records, hence with --relation one can for example extract only the FPIs
issued on the relation defined.  By default, the records are printed or
their stats computed (--stats), using --quiet would only save the images
without any output generated.

This is a tool aimed mostly for very experienced users, useful for
fixing page-level corruption or just analyzing the past state of a page,
and there were no easy way to do that with the in-core tools up to now
when looking at WAL.

Each block is saved in a separate file, to ease their manipulation, with
the file respecting <lsn>.<ts>.<db>.<rel>.<blk>_<fork> with as format.

For instance, 00000000-010000C0.1663.1.6117.123_main refers to:
- WAL record LSN in hexa format (00000000-010000C0).
- Tablespace OID (1663).
- Database OID (1).
- Relfilenode (6117).
- Block number (123).
- Fork name of the file this block came from (_main).

Author: David Christensen
Reviewed-by: Sho Kato, Justin Pryzby, Bharath Rupireddy, Matthias van de
Meent
Discussion: https://postgr.es/m/CAOxo6XKjQb2bMSBRpePf3ZpzfNTwjQUc4Tafh21=jzjX6bX8CA@mail.gmail.com
This commit is contained in:
Michael Paquier
2022-12-27 08:27:53 +09:00
parent 5de94a041e
commit d497093cbe
4 changed files with 286 additions and 0 deletions

View File

@ -240,6 +240,72 @@ PostgreSQL documentation
</listitem>
</varlistentry>
<varlistentry>
<term><option>--save-fullpage=<replaceable>save_path</replaceable></option></term>
<listitem>
<para>
Save full page images found in the WAL records to the
<replaceable>save_path</replaceable> directory. The images saved
are subject to the same filtering and limiting criteria as the
records displayed.
</para>
<para>
The full page images are saved with the following file name format:
<literal><replaceable>LSN</replaceable>.<replaceable>RELTABLESPACE</replaceable>.<replaceable>DATOID</replaceable>.<replaceable>RELNODE</replaceable>.<replaceable>BLKNO</replaceable><replaceable>FORK</replaceable></literal>
The file names are composed of the following parts:
<informaltable>
<tgroup cols="2">
<thead>
<row>
<entry>Component</entry>
<entry>Description</entry>
</row>
</thead>
<tbody>
<row>
<entry>LSN</entry>
<entry>The <acronym>LSN</acronym> of the record with this image,
formatted as two 8-character hexadecimal numbers
<literal>%08X-%08X</literal></entry>
</row>
<row>
<entry>RELTABLESPACE</entry>
<entry>tablespace OID of the block</entry>
</row>
<row>
<entry>DATOID</entry>
<entry>database OID of the block</entry>
</row>
<row>
<entry>RELNODE</entry>
<entry>filenode of the block</entry>
</row>
<row>
<entry>BLKNO</entry>
<entry>block number of the block</entry>
</row>
<row>
<entry>FORK</entry>
<entry>
The name of the fork the full page image came from, as of
<literal>_main</literal>, <literal>_fsm</literal>,
<literal>_vm</literal>, or <literal>_init</literal>.
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>-x <replaceable>xid</replaceable></option></term>
<term><option>--xid=<replaceable>xid</replaceable></option></term>