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 changedthe 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.