diff options
author | Michael Paquier <michael@paquier.xyz> | 2020-10-28 12:15:00 +0900 |
---|---|---|
committer | Michael Paquier <michael@paquier.xyz> | 2020-10-28 12:15:00 +0900 |
commit | f2b883969557f4572cdfa87e1a40083d2b1272e7 (patch) | |
tree | 4269340b2912f8dae50c29580a2ac8d9ec5a5bb8 /doc/src | |
parent | c780a7a90a8e7b074405ea2007e34f94e227e695 (diff) | |
download | postgresql-f2b883969557f4572cdfa87e1a40083d2b1272e7.tar.gz postgresql-f2b883969557f4572cdfa87e1a40083d2b1272e7.zip |
Add pg_relation_check_pages() to check on-disk pages of a relation
This makes use of CheckBuffer() introduced in c780a7a, adding a SQL
wrapper able to do checks for all the pages of a relation. By default,
all the fork types of a relation are checked, and it is possible to
check only a given relation fork. Note that if the relation given in
input has no physical storage or is temporary, then no errors are
generated, allowing full-database checks when coupled with a simple scan
of pg_class for example. This is not limited to clusters with data
checksums enabled, as clusters without data checksums can still apply
checks on pages using the page headers or for the case of a page full of
zeros.
This function returns a set of tuples consisting of:
- The physical file where a broken page has been detected (without the
segment number as that can be AM-dependent, which can be guessed from
the block number for heap). A relative path from PGPATH is used.
- The block number of the broken page.
By default, only superusers have an access to this function but
execution rights can be granted to other users.
The feature introduced here is still minimal, and more improvements
could be done, like:
- Addition of a start and end block number to run checks on a range
of blocks, which would apply only if one fork type is checked.
- Addition of some progress reporting.
- Throttling, with configuration parameters in function input or
potentially some cost-based GUCs.
Regression tests are added for positive cases in the main regression
test suite, and TAP tests are added for cases involving the emulation of
page corruptions.
Bump catalog version.
Author: Julien Rouhaud, Michael Paquier
Reviewed-by: Masahiko Sawada, Justin Pryzby
Discussion: https://postgr.es/m/CAOBaU_aVvMjQn=ge5qPiJOPMmOj5=ii3st5Q0Y+WuLML5sR17w@mail.gmail.com
Diffstat (limited to 'doc/src')
-rw-r--r-- | doc/src/sgml/func.sgml | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml index f7f401b534c..7ef2ec99725 100644 --- a/doc/src/sgml/func.sgml +++ b/doc/src/sgml/func.sgml @@ -26182,6 +26182,56 @@ SELECT convert_from(pg_read_binary_file('file_in_utf8.txt'), 'UTF8'); </sect2> + <sect2 id="functions-data-sanity"> + <title>Data Sanity Functions</title> + + <para> + The functions shown in <xref linkend="functions-data-sanity-table"/> + provide ways to check the sanity of data files in the cluster. + </para> + + <table id="functions-data-sanity-table"> + <title>Data Sanity Functions</title> + <tgroup cols="3"> + <thead> + <row><entry>Name</entry> <entry>Return Type</entry> <entry>Description</entry> + </row> + </thead> + + <tbody> + <row> + <entry> + <literal><function>pg_relation_check_pages(<parameter>relation</parameter> <type>regclass</type> [, <parameter>fork</parameter> <type>text</type> <literal>DEFAULT</literal> <literal>NULL</literal> ])</function></literal> + </entry> + <entry><type>setof record</type></entry> + <entry>Check the pages of a relation. + </entry> + </row> + </tbody> + </tgroup> + </table> + + <indexterm> + <primary>pg_relation_check_pages</primary> + </indexterm> + <para id="functions-check-relation-note" xreflabel="pg_relation_check_pages"> + <function>pg_relation_check_pages</function> iterates over all blocks of a + given relation and verifies if they are in a state where they can safely + be loaded into the shared buffers. If defined, + <replaceable>fork</replaceable> specifies that only the pages of the given + fork are to be verified. Fork can be <literal>'main'</literal> for the + main data fork, <literal>'fsm'</literal> for the free space map, + <literal>'vm'</literal> for the visibility map, or + <literal>'init'</literal> for the initialization fork. The default of + <literal>NULL</literal> means that all the forks of the relation are + checked. The function returns a list of blocks that are considered as + corrupted with the path of the related file. Use of this function is + restricted to superusers by default but access may be granted to others + using <command>GRANT</command>. + </para> + + </sect2> + </sect1> <sect1 id="functions-trigger"> |