pg_waldump
pg_waldump — display a human-readable rendering of the write-ahead log of a Postgres Pro database cluster
Synopsis
pg_waldump [option...] [timestamp-option...] [startseg [endseg]]
Description
pg_waldump displays the write-ahead log (WAL) and prints timestamps for WAL records. This utility is mainly useful for debugging or educational purposes.
This utility can only be run by the user who installed the server, because it requires read-only access to the data directory.
Options
The following command-line options control the location and format of the output:
startsegStart reading at the specified log segment file. This implicitly determines the path in which files will be searched for, and the timeline to use.
endsegStop after reading the specified log segment file.
-b--bkp-detailsOutput detailed information about backup blocks.
-eend--end=endStop reading at the specified WAL location, instead of reading to the end of the log stream.
-f--followAfter reaching the end of valid WAL, keep polling once per second for new WAL to appear.
-nlimit--limit=limitDisplay the specified number of records, then stop.
-ppath--path=pathSpecifies a directory to search for log segment files or a directory with a
pg_walsubdirectory that contains such files. The default is to search in the current directory, thepg_walsubdirectory of the current directory, and thepg_walsubdirectory ofPGDATA.-q--quietDo not print any output, except for errors. This option can be useful when you want to know whether a range of WAL records can be successfully parsed but don't care about the record contents.
-rrmgr--rmgr=rmgrOnly display records generated by the specified resource manager. If
listis passed as name, print a list of valid resource manager names, and exit.-sstart--start=startWAL location at which to start reading. The default is to start reading the first valid log record found in the earliest file found.
-ttimeline--timeline=timelineTimeline from which to read log records. The default is to use the value in
startseg, if that is specified; otherwise, the default is 1.-V--versionPrint the pg_waldump version and exit.
--save-fullpage=save_pathSave full page images found in the WAL records to the
save_pathdirectory. The images saved are subject to the same filtering and limiting criteria as the records displayed.The full page images are saved with the following file name format:
The file names are composed of the following parts:TIMELINE-LSN.RELTABLESPACE.DATOID.RELNODE.BLKNOFORKComponent Description TIMELINE The timeline of the WAL segment file where the record is located formatted as one 8-character hexadecimal number %08XLSN The LSN of the record with this image, formatted as two 8-character hexadecimal numbers %08X-%08XRELTABLESPACE tablespace OID of the block DATOID database OID of the block RELNODE filenode of the block BLKNO block number of the block FORK The name of the fork the full page image came from, as of _main,_fsm,_vm, or_init.-xxid--xid=xidOnly display records marked with the given transaction ID.
-z--stats[=record]Display summary statistics (number and size of records and full-page images) instead of individual records. Optionally generate statistics per-record instead of per-rmgr.
-?--helpShow help about pg_waldump command line arguments, and exit.
The following command-line options enable printing timestamps for various types of WAL records. You can use these options together with startseg, endseg, -s, and -e options.
-E--end-timestampPrint the timestamp of the last WAL record of the specified type found in the log segment file. When using this option, you must also specify the
-Soption.By default, pg_waldump prints timestamps only for COMMIT records. You can specify other record types using the
-Foption.-F[argument1,argument2,...]--timestamp-filter=argument[, ...]Specify WAL record types for which to print timestamps. When using this option, you must also specify the
-Soption.The
-Foption can take the following arguments, in the comma-separated format:XLOG_RESTORE_POINT— named restore points created with the pg_create_restore_point() function.XLOG_XACT_COMMIT— commit records for transactions. These records are caused by the COMMIT command.XLOG_XACT_COMMIT_PREPARED— commit records for transactions that were earlier prepared for a two-phase commit. These records are caused by the COMMIT PREPARED command.XLOG_XACT_ABORT— abort records for transactions. These records are caused by the ROLLBACK command.XLOG_XACT_ABORT_PREPARED— abort records for transactions that were earlier prepared for a two-phase commit. These records are caused by the ROLLBACK PREPARED command.
By default, pg_waldump prints timestamps only for COMMIT records.
-S--start-timestampPrint the timestamp of the first WAL record of the specified type found in the log segment file. This option is required if you are going to use
-Eor-Foptions.By default, pg_waldump prints timestamps only for COMMIT records. You can specify other record types using the
-Foption.
Environment
PGDATAData directory; see also the
-poption.PG_COLORSpecifies whether to use color in diagnostic messages. Possible values are
always,autoandnever.
Notes
Can give wrong results when the server is running.
Only the specified timeline is displayed (or the default, if none is specified). Records in other timelines are ignored.
pg_waldump cannot read WAL files with suffix .partial. If those files need to be read, .partial suffix needs to be removed from the file name.