avoid-revaccum-block-vacuumlazy.patch

application/octet-stream

Filename: avoid-revaccum-block-vacuumlazy.patch
Type: application/octet-stream
Part: 0
Message: lazy_scan_heap: avoid vacuum block, already vacuumed (src/backend/access/heap/vacuumlazy.c)

Patch

Same data as JSON: GET /api/v1/attachments/:id/patch the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes. API reference →
Format: unified
File+
src/backend/access/heap/vacuumlazy.c 5 1
diff --git a/src/backend/access/heap/vacuumlazy.c b/src/backend/access/heap/vacuumlazy.c
index 39395aed0d..cc5f4bc274 100644
--- a/src/backend/access/heap/vacuumlazy.c
+++ b/src/backend/access/heap/vacuumlazy.c
@@ -1375,10 +1375,14 @@ lazy_scan_heap(LVRelState *vacrel)
 			 * Vacuum the Free Space Map to make newly-freed space visible on
 			 * upper-level FSM pages. Note that blkno is the previously
 			 * processed block.
+			 * FreeSpaceMapVacuumRange uses an exclusive end,
+			 * so passing blkno + 1 covers blkno itself.  Advance
+			 * next_fsm_block_to_vacuum to blkno + 1 so the next call begins
+			 * at the first unvacuumed block and does not re-vacuum blkno.
 			 */
 			FreeSpaceMapVacuumRange(vacrel->rel, next_fsm_block_to_vacuum,
 									blkno + 1);
-			next_fsm_block_to_vacuum = blkno;
+			next_fsm_block_to_vacuum = blkno + 1;
 
 			/* Report that we are once again scanning the heap */
 			pgstat_progress_update_param(PROGRESS_VACUUM_PHASE,