At update of non-LP_NORMAL TID, fail instead of corrupting page header.
authorNoah Misch <noah@leadboat.com>
Sat, 25 Jan 2025 19:28:14 +0000 (11:28 -0800)
committerNoah Misch <noah@leadboat.com>
Sat, 25 Jan 2025 19:28:14 +0000 (11:28 -0800)
commitd28cd3e7b21c41a710fd9c188a57dad99f28805f
treeb4fb169ea6db1742fc13d5cc0cc2fcab54bcab3d
parent81772a495ec98d36eabf5cc294e7031a9545c5c1
At update of non-LP_NORMAL TID, fail instead of corrupting page header.

The right mix of DDL and VACUUM could corrupt a catalog page header such
that PageIsVerified() durably fails, requiring a restore from backup.
This affects only catalogs that both have a syscache and have DDL code
that uses syscache tuples to construct updates.  One of the test
permutations shows a variant not yet fixed.

This makes !TransactionIdIsValid(TM_FailureData.xmax) possible with
TM_Deleted.  I think core and PGXN are indifferent to that.

Per bug #17821 from Alexander Lakhin.  Back-patch to v13 (all supported
versions).  The test case is v17+, since it uses INJECTION_POINT.

Discussion: https://postgr.es/m/17821-dd8c334263399284@postgresql.org
src/backend/access/heap/heapam.c
src/backend/utils/cache/inval.c
src/include/access/tableam.h
src/test/modules/injection_points/Makefile
src/test/modules/injection_points/expected/syscache-update-pruned.out [new file with mode: 0644]
src/test/modules/injection_points/expected/syscache-update-pruned_1.out [new file with mode: 0644]
src/test/modules/injection_points/injection_points--1.0.sql
src/test/modules/injection_points/meson.build
src/test/modules/injection_points/regress_injection.c [new file with mode: 0644]
src/test/modules/injection_points/specs/syscache-update-pruned.spec [new file with mode: 0644]