Test that vacuum removes tuples older than OldestXmin
authorMelanie Plageman <melanieplageman@gmail.com>
Fri, 19 Jul 2024 15:20:07 +0000 (11:20 -0400)
committerMelanie Plageman <melanieplageman@gmail.com>
Fri, 19 Jul 2024 16:07:53 +0000 (12:07 -0400)
commitd42f60ccf07d89c12645efa8a41c57320d01c184
tree7a7e86a3c9315aee4d05b9fbc218a2f551bd9d0d
parent45ce054c02b8ac42909b8617819ff645e5c0487f
Test that vacuum removes tuples older than OldestXmin

If vacuum fails to prune a tuple killed before OldestXmin, it will later
find that tuple dead in lazy_scan_prune() and loop infinitely.

Add a test reproducing this scenario to the recovery suite which creates
a table on a primary, updates the table to generate dead tuples for
vacuum, and then, during the vacuum, uses a replica to force
GlobalVisState->maybe_needed on the primary to move backwards and
precede the value of OldestXmin set at the beginning of vacuuming the
table.

This commit is separate from the fix in case there are test stability
issues.

Discussion of the bug: https://postgr.es/m/CAAKRu_Y_NJzF4-8gzTTeaOuUL3CcGoXPjXcAHbTTygT8AyVqag%40mail.gmail.com
Discussion of the test: https://postgr.es/m/CAAKRu_apNU2MPBK96V%2BbXjTq0RiZ-%3DA4ZTaysakpx9jxbq1dbQ%40mail.gmail.com

Author: Melanie Plageman
Reviewed-by: Peter Geoghegan
src/test/recovery/t/043_vacuum_horizon_floor.pl [new file with mode: 0644]