1
0
mirror of https://github.com/postgres/postgres.git synced 2026-10-23 13:29:09 +03:00

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
This commit is contained in:
Peter Geoghegan
2026-10-14 14:26:04 -04:00
parent 2ad0b0f8c1
commit 4f45920f04

View File

@@ -1439,12 +1439,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;
}