HOT chain validation in verify_heapam()
Himanshu Upadhyaya <upadhyaya.himanshu@gmail.com>
From: Himanshu Upadhyaya <upadhyaya.himanshu@gmail.com>
To: Andres Freund <andres@anarazel.de>, robertmhaas@gmail.com
Cc: Peter Geoghegan <pg@bowt.ie>,
PostgreSQL Hackers <pgsql-hackers@postgresql.org>, Andrew Dunstan <andrew@dunslane.net>,
Mark Dilger <mark.dilger@enterprisedb.com>
Date: 2022-08-26T06:20:08Z
Lists: pgsql-hackers
Attachments
- v1-0001-HOT-chain-validation-in-verify_heapam.patch (application/x-patch) patch v1-0001
Hi, On Mon, Apr 4, 2022 at 11:46 PM Andres Freund <andres@anarazel.de> wrote: > > I think there's a few more things that'd be good to check. For example > amcheck > doesn't verify that HOT chains are reasonable, which can often be spotted > looking at an individual page. Which is a bit unfortunate, given how many > bugs > we had in that area. > > Stuff to check around that: > - target of redirect has HEAP_ONLY_TUPLE, HEAP_UPDATED set > - In a valid ctid chain within a page (i.e. xmax = xmin): > - tuples have HEAP_UPDATED set > - HEAP_ONLY_TUPLE / HEAP_HOT_UPDATED matches across chains elements (I changed the subject because the attached patch is related to HOT chain validation). Please find attached the patch with the above idea of HOT chain's validation(within a Page) and a few more validation as below. * If the predecessor’s xmin is aborted or in progress, the current tuples xmin should be aborted or in progress respectively. Also, Both xmin must be equal. * If the predecessor’s xmin is not frozen, then-current tuple’s shouldn’t be either. * If the predecessor’s xmin is equal to the current tuple’s xmin, the current tuple’s cmin should be greater than the predecessor’s xmin. * If the current tuple is not HOT then its predecessor’s tuple must not be HEAP_HOT_UPDATED. * If the current Tuple is HOT then its predecessor’s tuple must be HEAP_HOT_UPDATED and vice-versa. * If xmax is 0, which means it's the last tuple in the chain, then it must not be HEAP_HOT_UPDATED. * If the current tuple is the last tuple in the HOT chain then the next tuple should not be HOT. I am looking into the process of adding the TAP test for these changes and finding a way to corrupt a page in the tap test. Will try to include these test cases in my Upcoming version of the patch. -- Regards, Himanshu Upadhyaya EnterpriseDB: http://www.enterprisedb.com
Commits
-
amcheck: Generalize one of the recently-added update chain checks.
- c87aff065c33 16.0 landed
-
amcheck: Tighten up validation of redirect line pointers.
- 80d5e3a61551 16.0 landed
-
amcheck: Fix verify_heapam for tuples where xmin or xmax is 0.
- 8fd5aa76c367 14.8 landed
- 701ec5557968 15.3 landed
- e88754a1965c 16.0 landed
-
amcheck: Fix a few bugs in new update chain validation.
- 949e2e7c4f68 16.0 landed
-
Fix new test case to work on (some?) big-endian architectures.
- c75a623304bc 16.0 landed
-
Don't test HEAP_XMAX_INVALID when freezing xmax.
- 02d647bbf057 16.0 landed