diff options
author | Melanie Plageman <melanieplageman@gmail.com> | 2024-07-19 10:44:36 -0400 |
---|---|---|
committer | Melanie Plageman <melanieplageman@gmail.com> | 2024-07-19 12:11:41 -0400 |
commit | 06bf404cd07bd82f08a3000d5977080f945e70ca (patch) | |
tree | 2b5bb24e13b814f901be8933445c2dc9d3d81933 /src/include/access/heapam.h | |
parent | d97f2ee50e49046a984665fb72fa14a06bd58435 (diff) |
Ensure vacuum removes all visibly dead tuples older than OldestXmin
If vacuum fails to remove a tuple with xmax older than
VacuumCutoffs->OldestXmin and younger than GlobalVisState->maybe_needed,
it will loop infinitely in lazy_scan_prune(), which compares tuples'
visibility information to OldestXmin.
Starting in version 14, which uses GlobalVisState for visibility testing
during pruning, it is possible for GlobalVisState->maybe_needed to
precede OldestXmin if maybe_needed is forced to go backward while vacuum
is running. This can happen if a disconnected standby with a running
transaction older than VacuumCutoffs->OldestXmin reconnects to the
primary after vacuum initially calculates GlobalVisState and OldestXmin.
Fix this by having vacuum always remove tuples older than OldestXmin
during pruning. This is okay because the standby won't replay the tuple
removal until the tuple is removable. Thus, the worst that can happen is
a recovery conflict.
Fixes BUG# 17257
Back-patched in versions 14-17
Author: Melanie Plageman
Reviewed-by: Noah Misch, Peter Geoghegan, Robert Haas, Andres Freund, and Heikki Linnakangas
Discussion: https://postgr.es/m/CAAKRu_Y_NJzF4-8gzTTeaOuUL3CcGoXPjXcAHbTTygT8AyVqag%40mail.gmail.com
Diffstat (limited to 'src/include/access/heapam.h')
-rw-r--r-- | src/include/access/heapam.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/src/include/access/heapam.h b/src/include/access/heapam.h index faf50265191..c7278219b24 100644 --- a/src/include/access/heapam.h +++ b/src/include/access/heapam.h @@ -285,6 +285,7 @@ extern TransactionId heap_index_delete_tuples(Relation rel, struct GlobalVisState; extern void heap_page_prune_opt(Relation relation, Buffer buffer); extern int heap_page_prune(Relation relation, Buffer buffer, + TransactionId oldest_xmin, struct GlobalVisState *vistest, TransactionId old_snap_xmin, TimestampTz old_snap_ts, |