]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Include last block in FSM vacuum of bulk extended relation
authorMelanie Plageman <melanieplageman@gmail.com>
Wed, 15 Jul 2026 19:49:59 +0000 (15:49 -0400)
committerMelanie Plageman <melanieplageman@gmail.com>
Wed, 15 Jul 2026 19:52:43 +0000 (15:52 -0400)
When bulk-extending a relation, we add the newly-added blocks that we
won't immediately use to the free space map and then call
FreeSpaceMapVacuumRange() to propagate that free space up the FSM tree,
so other backends can find and reuse it.

However, the end block argument to FreeSpaceMapVacuumRange() is
exclusive, and we passed the number of the last added block (since
00d1e02be24). If that block was the first one covered by a new FSM page,
its free space wasn't propagated up the tree and was therefore invisible
to FSM searches until the next FSM vacuum.

Fix by passing the block number one past the last added block, so the
full range is vacuumed.

Author: Jingtang Zhang <mrdrivingduck@gmail.com>
Reviewed-by: Melanie Plageman <melanieplageman@gmail.com>
Discussion: https://postgr.es/m/flat/CAPsk3_Bx_vdybN%3D-DZu8HLStf%2BXnuFUBkLwxouONSMkWuO9oug%40mail.gmail.com
Backpatch-through: 16

src/backend/access/heap/hio.c

index e96e0f77d9264996ea9eb7670aaefb2a8a9f99b3..fb4ffb975926295ee19f0bc6f8b121f21b945689 100644 (file)
@@ -401,7 +401,7 @@ RelationAddBlocks(Relation relation, BulkInsertState bistate,
        {
                BlockNumber first_fsm_block = first_block + not_in_fsm_pages;
 
-               FreeSpaceMapVacuumRange(relation, first_fsm_block, last_block);
+               FreeSpaceMapVacuumRange(relation, first_fsm_block, last_block + 1);
        }
 
        if (bistate)