|From:||Tomas Vondra <tomas(dot)vondra(at)2ndquadrant(dot)com>|
|Subject:||PATCH: pageinspect / add page_checksum and bt_page_items(bytea)|
|Views:||Raw Message | Whole Thread | Download mbox|
while investigating some checksum-related issues, I needed to perform
some forensics on a copy of a btree page (taken from another instance
But I've ran into two pageinspect limitations, hopefully addressed by
1) bt_page_items(bytea) not defined
We have heap_page_items(bytea) but not bt_page_items(bytea). I suspect
this is partially historical API inconsistence, and partially due to the
need to handle the btree metapage explicitly.
The original function simply threw an error with blkno=0, the new
function simply checks for BTP_META page.
I believe this is sufficient, assuming the instance without data
corruption (which pageinspect assumes anyway). With data corruption all
bets are off anyway - for example the metapage might be written to a
different block (essentially what I saw in the investigated issue).
Actually, the flag check is better in this case - it detects the
metapage, while the blkno=0 check fails to do that (leading to crash).
When everything is fine, you can do page_header() which also includes
the checksum. When the checksum gets broken, you may still dump the page
using 'dd+pg_read_binary_file' to see the header, but clearly that
checksum is wrong - and it's interesting to see the correct one and
compare it to the checksum in the header.
This function makes it possible - it accepts the bytea image of the
page, and blkno (so it's possible to see how would the block look if it
was written somewhere else, for example).
BTW I've noticed the pageinspect version is 1.6, but we only have
pageinspect--1.5.sql (and upgrade script to 1.6). Not sure that's
Tomas Vondra http://www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
|Next Message||Christoph Berg||2017-02-20 16:15:56||Re: powerpc(32) point/polygon regression failures on Debian Jessie|
|Previous Message||Tom Lane||2017-02-20 16:12:23||Re: powerpc(32) point/polygon regression failures on Debian Jessie|