Properly acquire buffer lock for page-at-a-time hash vacuum.
In a couple of places, _hash_kill_items was mistakenly called with the buffer lock not held. Repair. Ashutosh Sharma, per a report from Andreas Seltenreich Discussion: http://postgr.es/m/87o9wo8o0j.fsf@credativ.de
This commit is contained in:
parent
f578093526
commit
93cd7684ee
@ -476,9 +476,17 @@ hashrescan(IndexScanDesc scan, ScanKey scankey, int nscankeys,
|
|||||||
HashScanOpaque so = (HashScanOpaque) scan->opaque;
|
HashScanOpaque so = (HashScanOpaque) scan->opaque;
|
||||||
Relation rel = scan->indexRelation;
|
Relation rel = scan->indexRelation;
|
||||||
|
|
||||||
/* Before leaving current page, deal with any killed items */
|
/*
|
||||||
|
* Before leaving current page, deal with any killed items.
|
||||||
|
* Also, ensure that we acquire lock on current page before
|
||||||
|
* calling _hash_kill_items.
|
||||||
|
*/
|
||||||
if (so->numKilled > 0)
|
if (so->numKilled > 0)
|
||||||
|
{
|
||||||
|
LockBuffer(so->hashso_curbuf, BUFFER_LOCK_SHARE);
|
||||||
_hash_kill_items(scan);
|
_hash_kill_items(scan);
|
||||||
|
LockBuffer(so->hashso_curbuf, BUFFER_LOCK_UNLOCK);
|
||||||
|
}
|
||||||
|
|
||||||
_hash_dropscanbuf(rel, so);
|
_hash_dropscanbuf(rel, so);
|
||||||
|
|
||||||
@ -507,9 +515,17 @@ hashendscan(IndexScanDesc scan)
|
|||||||
HashScanOpaque so = (HashScanOpaque) scan->opaque;
|
HashScanOpaque so = (HashScanOpaque) scan->opaque;
|
||||||
Relation rel = scan->indexRelation;
|
Relation rel = scan->indexRelation;
|
||||||
|
|
||||||
/* Before leaving current page, deal with any killed items */
|
/*
|
||||||
|
* Before leaving current page, deal with any killed items.
|
||||||
|
* Also, ensure that we acquire lock on current page before
|
||||||
|
* calling _hash_kill_items.
|
||||||
|
*/
|
||||||
if (so->numKilled > 0)
|
if (so->numKilled > 0)
|
||||||
|
{
|
||||||
|
LockBuffer(so->hashso_curbuf, BUFFER_LOCK_SHARE);
|
||||||
_hash_kill_items(scan);
|
_hash_kill_items(scan);
|
||||||
|
LockBuffer(so->hashso_curbuf, BUFFER_LOCK_UNLOCK);
|
||||||
|
}
|
||||||
|
|
||||||
_hash_dropscanbuf(rel, so);
|
_hash_dropscanbuf(rel, so);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user