Assert redirect pointers are sensible after heap_page_prune().
authorAndres Freund <andres@anarazel.de>
Mon, 22 Nov 2021 17:52:45 +0000 (09:52 -0800)
committerAndres Freund <andres@anarazel.de>
Fri, 14 Jan 2022 02:14:05 +0000 (18:14 -0800)
commitbb42bfb5ccb5f138a8b7ad3549cfb05c0cc5187b
tree259cc184fe9b21b9d18fcabacdc6ea77b9a8ec93
parent18b87b201f73a1ffb1a2cf941789610e0da6e621
Assert redirect pointers are sensible after heap_page_prune().

Corruption of redirect item pointers often only becomes visible well after
being corrupted, as e.g. bug #17255 shows: In the original reproducer,
gigabyte of WAL were between the source of the corruption and the corruption
becoming visible.

To make it easier to find / prevent such bugs, verify whether redirect
pointers are sensible at the end of heap_page_prune_execute(). 5cd7eb1f1c32
introduced related assertions while modifying the page, but they can't easily
detect marking the target of an existing redirect as unused. Sometimes the
corruption will be detected later, but that's harder to diagnose.

Author: Andres Freund <andres@andres@anarazel.de>
Reviewed-By: Peter Geoghegan <pg@bowt.ie>
Discussion: https://postgr.es/m/20211122175914.ayk6gg6nvdwuhrzb@alap3.anarazel.de
src/backend/access/heap/pruneheap.c