[HACKERS] PATCH: pageinspect / add page_checksum and bt_page_items(bytea)
От | Tomas Vondra |
---|---|
Тема | [HACKERS] PATCH: pageinspect / add page_checksum and bt_page_items(bytea) |
Дата | |
Msg-id | ef0eb8aa-542b-9fd0-a7a2-d99a9bed38da@2ndquadrant.com обсуждение исходный текст |
Ответы |
Re: [HACKERS] PATCH: pageinspect / add page_checksum and bt_page_items(bytea)
|
Список | pgsql-hackers |
Hi, while investigating some checksum-related issues, I needed to perform some forensics on a copy of a btree page (taken from another instance using 'dd'). But I've ran into two pageinspect limitations, hopefully addressed by this patch: 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). 2) page_checksum() 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 entirely intentional? regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Вложения
В списке pgsql-hackers по дате отправления: