pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Paquier <michael@paquier.xyz>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Add pg_relation_check_pages() to check on-disk pages of a relati
Date: Wed, 28 Oct 2020 03:15:53 +0000
Message-ID: <E1kXbwH-0006Jz-9q@gemulon.postgresql.org> (raw)

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

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/f2b883969557f4572cdfa87e1a40083d2b1272e7

Modified Files
--------------
doc/src/sgml/func.sgml                  |  50 +++++++
src/backend/catalog/system_views.sql    |   9 ++
src/backend/utils/adt/Makefile          |   1 +
src/backend/utils/adt/pagefuncs.c       | 229 +++++++++++++++++++++++++++++++
src/include/catalog/catversion.h        |   2 +-
src/include/catalog/pg_proc.dat         |   7 +
src/test/recovery/t/022_page_check.pl   | 231 ++++++++++++++++++++++++++++++++
src/test/regress/expected/pagefuncs.out |  72 ++++++++++
src/test/regress/parallel_schedule      |   2 +-
src/test/regress/serial_schedule        |   1 +
src/test/regress/sql/pagefuncs.sql      |  41 ++++++
src/tools/pgindent/typedefs.list        |   1 +
12 files changed, 644 insertions(+), 2 deletions(-)



view thread (5+ messages)  latest in thread

Message-ID: <E1kXbwH-0006Jz-9q@gemulon.postgresql.org>
Permalink:  ../E1kXbwH-0006Jz-9q@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1kXbwH-0006Jz-9q@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: michael@paquier.xyz, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Add pg_relation_check_pages() to check on-disk pages of a relati
  In-Reply-To: <E1kXbwH-0006Jz-9q@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox