postgres.git / summary / log / commit / refs

commit    0fd5595aa3e71e54a297b18bc104f487c8555550
Author:   Melanie Plageman <melanieplageman@gmail.com>
Date:     Wed Jul 15 19:49:59 2026 +0000
First released in: 16.15, 17.11, 18.6

    Include last block in FSM vacuum of bulk extended relation
    
    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 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backend/access/heap/hio.c b/src/backend/access/heap/hio.c index ccc4c6966a2..390db47d44e 100644 --- a/src/backend/access/heap/hio.c +++ b/src/backend/access/heap/hio.c @@ -404,7 +404,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) [parent: c184d6ec1962]