From afac3bfc209ca6ee236cb9e796395b2bd34ca838 Mon Sep 17 00:00:00 2001 From: Bharath Rupireddy Date: Wed, 16 Mar 2022 07:38:52 +0000 Subject: [PATCH v10] pg_walinspect docs --- doc/src/sgml/contrib.sgml | 1 + doc/src/sgml/filelist.sgml | 1 + doc/src/sgml/pgwalinspect.sgml | 202 +++++++++++++++++++++++++++++++++ 3 files changed, 204 insertions(+) create mode 100644 doc/src/sgml/pgwalinspect.sgml diff --git a/doc/src/sgml/contrib.sgml b/doc/src/sgml/contrib.sgml index 1e42ce1a7f..4e7b87a42f 100644 --- a/doc/src/sgml/contrib.sgml +++ b/doc/src/sgml/contrib.sgml @@ -131,6 +131,7 @@ CREATE EXTENSION module_name; &pgsurgery; &pgtrgm; &pgvisibility; + &pgwalinspect; &postgres-fdw; &seg; &sepgsql; diff --git a/doc/src/sgml/filelist.sgml b/doc/src/sgml/filelist.sgml index fd853af01f..34c19c80f1 100644 --- a/doc/src/sgml/filelist.sgml +++ b/doc/src/sgml/filelist.sgml @@ -147,6 +147,7 @@ + diff --git a/doc/src/sgml/pgwalinspect.sgml b/doc/src/sgml/pgwalinspect.sgml new file mode 100644 index 0000000000..d47d98b91e --- /dev/null +++ b/doc/src/sgml/pgwalinspect.sgml @@ -0,0 +1,202 @@ + + + + pg_walinspect + + + pg_walinspect + + + + The pg_walinspect module provides functions that allow + you to inspect the contents of write-ahead log of PostgreSQL + database cluster at a low level, which is useful for debugging or analytical + or reporting or educational purposes. + + + + All the functions of this module will provide the WAL information using the + current server's timeline ID. + + + + General Functions + + + + + + pg_get_raw_wal_record(in_lsn pg_lsn, + start_lsn OUT pg_lsn, + end_lsn OUT pg_lsn, + record_length OUT int4, + record OUT bytea) + + + + + + Gets raw WAL record data of a given LSN. This function emits an error if + a future (the LSN database system doesn't know about) in_lsn + is specified. + + + + By default, use of this function is restricted to superusers and members + of the pg_read_server_files role. Access may be + granted by superusers to others using GRANT. + + + + + + + + pg_get_wal_record_info(in_lsn pg_lsn, + start_lsn OUT pg_lsn, + end_lsn OUT pg_lsn, + prev_lsn OUT pg_lsn, + xid OUT xid, + resource_manager OUT text, + record_length OUT int4, + fpi_length OUT int4, + description OUT text, + block_ref OUT text, + data_length OUT int4, + data OUT bytea) + + + + + + Gets WAL record information of the given LSN. This function emits an + error if a future (the LSN database system doesn't know about) in_lsn + is specified. + + + + By default, use of this function is restricted to superusers and members + of the pg_monitor role. Access may be granted by + superusers to others using GRANT. + + + + + + + + pg_get_wal_records_info(start_lsn pg_lsn, + end_lsn pg_lsn, + start_lsn OUT pg_lsn, + end_lsn OUT pg_lsn, + prev_lsn OUT pg_lsn, + xid OUT xid, + resource_manager OUT text, + record_length OUT int4, + fpi_length OUT int4, + description OUT text, + block_ref OUT text, + data_length OUT int4, + data OUT bytea) + returns setof record + + + + + + Gets information of all the valid WAL records between start_lsn + and end_lsn. Returns one row per each valid + WAL record. This function figures out the end_lsn + if it's not specified, that means, it returns information up to the end + of WAL. Default value of end_lsn is + NULL. This function emits an error if a future (the + LSN database system doesn't know about) start_lsn + or end_lsn is specified. For example: + +postgres=# select start_lsn, end_lsn, prev_lsn, xid, resource_manager, record_length, fpi_length, block_ref, data_length from pg_get_wal_records_info('0/1602790', '0/16038D0'); + start_lsn | end_lsn | prev_lsn | xid | resource_manager | record_length | fpi_length | block_ref | data_length +-----------+-----------+-----------+-----+------------------+---------------+------------+--------------------------------------------------------------------------+------------- + 0/1602790 | 0/16027C7 | 0/1602758 | 0 | Standby | 50 | 0 | | 24 + 0/16027C8 | 0/160283F | 0/1602790 | 0 | XLOG | 114 | 0 | | 88 + 0/1602840 | 0/1602877 | 0/16027C8 | 0 | Standby | 50 | 0 | | 24 + 0/1602878 | 0/16028AF | 0/1602840 | 0 | Standby | 50 | 0 | | 24 + 0/16028B0 | 0/1602927 | 0/1602878 | 0 | XLOG | 114 | 0 | | 88 + 0/1602928 | 0/16037AF | 0/16028B0 | 751 | Heap | 3714 | 3660 | blkref #0: rel 1663/5/24628 blk 0 (FPW); hole: offset: 428, length: 4532 | 3 + 0/16037B0 | 0/16037EF | 0/1602928 | 751 | Heap | 59 | 0 | blkref #0: rel 1663/5/24628 blk 0 | 3 + 0/16037F0 | 0/160382F | 0/16037B0 | 751 | Heap | 59 | 0 | blkref #0: rel 1663/5/24628 blk 0 | 3 + 0/1603830 | 0/160386F | 0/16037F0 | 751 | Heap | 59 | 0 | blkref #0: rel 1663/5/24628 blk 0 | 3 + 0/1603870 | 0/16038A7 | 0/1603830 | 0 | Standby | 54 | 0 | | 28 + 0/16038A8 | 0/16038CF | 0/1603870 | 751 | Transaction | 34 | 0 | | 8 +(11 rows) + + + + + By default, use of this function is restricted to superusers and members + of the pg_monitor role. Access may be granted by + superusers to others using GRANT. + + + + + + + + pg_get_wal_stats(start_lsn pg_lsn, + end_lsn pg_lsn, + resource_manager OUT text, + count OUT int8, + count_percentage OUT float4, + record_length OUT int8, + record_length_percentage OUT float4, + fpi_length OUT int8, + fpi_length_percentage OUT float4) + returns setof record + + + + + + Gets statistics of all the valid WAL records between start_lsn + and end_lsn. Returns one row per each resource_manager + type. This function figures out the end_lsn if + it's not specified, that means, it returns information up to the end of + WAL. Default value of end_lsn is + NULL. This function emits an error if a future (the + LSN database system doesn't know about) start_lsn + or end_lsn is specified. For example: + +postgres=# select * from pg_get_wal_stats('0/15E80C0', '0/1600000'); + resource_manager | count | count_percentage | record_length | record_length_percentage | fpi_length | fpi_length_percentage +------------------+-------+------------------+---------------+--------------------------+------------+----------------------- + Storage | 1 | 0.7 | 42 | 0.04 | 0 | 0 + Btree | 27 | 18.88 | 65116 | 66.98 | 63456 | 72.45 + Heap | 101 | 70.63 | 7697 | 7.92 | 1596 | 1.82 + Transaction | 1 | 0.7 | 405 | 0.42 | 0 | 0 + Heap2 | 6 | 4.2 | 23573 | 24.25 | 22532 | 25.73 + Standby | 5 | 3.5 | 242 | 0.25 | 0 | 0 + XLOG | 2 | 1.4 | 144 | 0.15 | 0 | 0 +(7 rows) + + + + + By default, use of this function is restricted to superusers and members + of the pg_monitor role. Access may be granted by + superusers to others using GRANT. + + + + + + + + + Author + + + Bharath Rupireddy bharath.rupireddyforpostgres@gmail.com + + + + -- 2.25.1