From 3d88e92cc94766f9d30b819e59df6026dbffe4d6 Mon Sep 17 00:00:00 2001 From: Masahiko Sawada Date: Fri, 4 Apr 2025 14:43:56 -0700 Subject: [PATCH] Fix periodic FSM vacuum not triggering in one-pass strategy vacuum. Since c120550edb86, we optimized the vacuuming of relations without indexes by directly marking items as LP_UNUSED instead of LP_DEAD during pruning. However, we continued to check has_lpdead_items in the condition for periodic FSM vacuum (which occurs every VACUUM_FSM_EVERY_PAGES). This patch removes the has_lpdead_items check from that condition. Backpatch to version 17, where we introduced the pruning optimization. Reviewed-by: Melanie Plageman Discussion: https://postgr.es/m/CAD21AoBL8m6B9GSzQfYxVaEgvD7-Kr3AJaS-hJPHC+avm-29zw@mail.gmail.com Backpatch-through: 17 --- src/backend/access/heap/vacuumlazy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backend/access/heap/vacuumlazy.c b/src/backend/access/heap/vacuumlazy.c index f28326bad09..a163004da38 100644 --- a/src/backend/access/heap/vacuumlazy.c +++ b/src/backend/access/heap/vacuumlazy.c @@ -1475,7 +1475,7 @@ lazy_scan_heap(LVRelState *vacrel) * table has indexes. There will only be newly-freed space if we * held the cleanup lock and lazy_scan_prune() was called. */ - if (got_cleanup_lock && vacrel->nindexes == 0 && has_lpdead_items && + if (got_cleanup_lock && vacrel->nindexes == 0 && blkno - next_fsm_block_to_vacuum >= VACUUM_FSM_EVERY_PAGES) { FreeSpaceMapVacuumRange(vacrel->rel, next_fsm_block_to_vacuum, -- 2.43.5