postgres.git / summary / log / commit / refs

commit    3eaa726e7be562bc6231e01bd8620909df4fb6b7
Author:   Peter Geoghegan <pg@bowt.ie>
Date:     Wed Oct 14 18:26:04 2026 +0000
First released in: 14.25, 15.20, 16.16, 17.12, 18.7, 19.0

    Fix hash bucket split buffer pin leak.
    
    The process by which a hash index inserter finishes an incomplete bucket
    split involves a walk of the new bucket (the bucket "being populated")
    to collect the TIDs that the interrupted split already moved.  This
    process keeps a pin on the new bucket's primary page, and then takes
    conditional cleanup locks on both buckets.  When either lock could not
    be acquired, we gave up, but neglected to release the new bucket's pin.
    
    To fix, release the buffer pin on failure.
    
    Oversight in commit 6d46f4783, which improved hash index bucket split
    behavior by switching it from using a heavyweight lock to using these
    cleanup locks.
    
    Author: Peter Geoghegan <pg@bowt.ie>
    Reviewed-by: Ayush Tiwari <ayushtiwari.slg01@gmail.com>
    Discussion: https://postgr.es/m/CAH2-Wz=b9sSBv15HsgZAuazjJu8-YRGHOpLjvp+dJgEDaBx0Ng@mail.gmail.com
    Backpatch-through: 14


src/backend/access/hash/hashpage.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/backend/access/hash/hashpage.c b/src/backend/access/hash/hashpage.c index 14bde24e4de..983941c237e 100644 --- a/src/backend/access/hash/hashpage.c +++ b/src/backend/access/hash/hashpage.c @@ -1438,12 +1438,14 @@ _hash_finish_split(Relation rel, Buffer metabuf, Buffer obuf, Bucket obucket, */ if (!ConditionalLockBufferForCleanup(obuf)) { + _hash_dropbuf(rel, bucket_nbuf); hash_destroy(tidhtab); return; } if (!ConditionalLockBufferForCleanup(bucket_nbuf)) { LockBuffer(obuf, BUFFER_LOCK_UNLOCK); + _hash_dropbuf(rel, bucket_nbuf); hash_destroy(tidhtab); return; } [parent: 4776a9ac0a7e]