White-box testing heap pruning

From: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, Melanie Plageman <melanieplageman(at)gmail(dot)com>
Subject: White-box testing heap pruning
Date: 2024-04-14 20:34:55
Message-ID: 23e3e8be-4a29-4d03-8b17-6e5e7e3869a5@iki.fi
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

While working on the "Combine Prune and Freeze records emitted by
vacuum" patch [1], I wished we would have an easier way to test pruning.
There's a lot of logic with following HOT chains etc., and it's very
hard to construct all those scenarios just by INSERT/UPDATE/DELETE
commands. In principle though, pruning should be very amenable for good
test coverage. The input is one heap page and some parameters, the
output is one heap page and a few other fields that are already packaged
neatly in the PruneFreezeResult struct.

Back then, I started to work on a little tool for that to verify the
correctness of pruning refactoring, but I never got around to polish it
or write proper repeatable tests with it. I did use it for some ad hoc
testing, though.

I don't know when I'll find the time to polish it, so here is the very
rough work-in-progress version I've got now.

One thing I used this for was to test that we still handle
HEAP_MOVED_IN/OFF correctly. Yes, it still works. But what surprised me
is that when a HEAP_MOVED_IN tuple is frozen, we replace xvac with
FrozenTransactondId, and leave the HEAP_MOVED_IN flag in place. I
assumed that we would clear the HEAP_MOVED_IN flag instead.

[1]
https://www.postgresql.org/message-id/CAAKRu_azf-zH%3DDgVbquZ3tFWjMY1w5pO8m-TXJaMdri8z3933g%40mail.gmail.com

--
Heikki Linnakangas
Neon (https://neon.tech)

Attachment Content-Type Size
0001-Expose-conflict_xid-to-caller-for-tests.patch text/x-patch 3.0 KB
0002-XXX-Add-test_heapam.patch text/x-patch 34.1 KB

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2024-04-14 22:33:05 Differential code coverage between 16 and HEAD
Previous Message Maksim Milyutin 2024-04-14 18:16:15 Re: Extension Enhancement: Buffer Invalidation in pg_buffercache