| From: | Andrey Borodin <x4mmm(at)yandex-team(dot)ru> |
|---|---|
| To: | pgsql-hackers mailing list <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Cc: | Mark Dilger <mark(dot)dilger(at)enterprisedb(dot)com> |
| Subject: | amcheck: detect corruption from the recent snapshot-export bug |
| Date: | 2026-10-04 13:50:57 |
| Message-ID: | B993F6CC-03D0-440F-9D7C-FEF65D19C082@yandex-team.ru |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi hackers!
I was investigating foreign-key violations reported by a user after
failover. Some tuples had HEAP_XMIN_INVALID set despite their xmin being
committed in pg_xact. During the investigation I found the recent
snapshot-export bug thread [0], with a fix already committed.
pg_visibility reported the affected tuples on the standby, but
verify_heapam() did not. We routinely run verify_heapam() and would like
it to catch this damage without having to scan the same tables again
with pg_visibility.
PFA a two-patch series. 0001 detects this damage by reporting
HEAP_XMIN_INVALID when xmin is known to have committed. It excludes
old-style VACUUM FULL tuples and does not treat an assumed commit after
pg_xact truncation as evidence of corruption.
I think it would be good to have such check backpatched along with the
corruption fix.
0002 revisits the related xmin/xmax checks I proposed in 2024 [1]. It
checks committed hints against aborted transactions, and invalid xmax
hints against committed updaters, including multixact members. I kept
these separate so that we can address the known corruption first.
The first patch's test also covers HEAP_MOVED_IN, though I'm not sure
it's worth adding coverage for this old VACUUM FULL format.
I am still thinking about how best to repair the existing damage.
Thank you!
Best regards, Andrey Borodin.
[0] https://postgr.es/m/CAH2-WzmHVeYY%3Dpjz9x8DhhxVjXHX0pvoQ-MdiB1Tt6%3Do2GTiKg%40mail.gmail.com
[1] https://postgr.es/m/BE90C4F8-9A37-40AD-A5CC-9818BBE59BCC@yandex-team.ru
| Attachment | Content-Type | Size |
|---|---|---|
| v1-0001-Detect-incorrect-HEAP_XMIN_INVALID-hints-in-verif.patch | application/octet-stream | 10.4 KB |
| v1-0002-Detect-more-inconsistent-transaction-hints-in-ver.patch | application/octet-stream | 10.1 KB |
| From | Date | Subject | |
|---|---|---|---|
| Previous Message | CharSyam | 2026-10-04 13:49:50 | [PATCH] Fix default partition validation for reordered child columns |