offline consistency check and info on attributes - Mailing list pgsql-hackers

From Tomas Vondra
Subject offline consistency check and info on attributes
Date
Msg-id 4DB4549B.3060109@fuzzy.cz
Whole thread Raw
Responses Re: offline consistency check and info on attributes  (Alvaro Herrera <alvherre@commandprompt.com>)
List pgsql-hackers
Hi,

a recent discussion about possible data corruption (in the general list)
suggests that a tool for offline integrity check might be useful.
Something that might be run when the database is shut down, to check
that the data files are OK.

The idea is to read all heap blocks and check for various 'suspicious'
things like 'pd_lower > pd_upper', invalid lengths (negative lengths,
resulting in in alloc errors) etc. It might list blocks that are somehow
corrupted, dump them in a separate file etc.

Right now I do have a very simple tool that reads a given file and
performs a lot of checks at the block level (as described in bufpage.h),
and the next step should be validating basic structure of the tuples
(lengths). And that's the point where I'm stuck right now - I'm thinking
what might be the most elegant way to get info about attributes, without
access to the pg_attribute catalog (the tool is intended for offline
checks).

I've figured out the catalog-to-file mapping (in relmapper.c), but now
I'm wondering - it's just another relation, so I'd have to read the
block, parse the items and interpret them (not sure how to do that
without the pg_attribute data itself). So I wonder - what would be an
elegant solution?

regards
Tomas


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: windows consolidated cleanup
Next
From: Yves Weißig
Date:
Subject: operator classes for index?