@@ -476,9 +476,17 @@ hashrescan(IndexScanDesc scan, ScanKey scankey, int nscankeys,
476
476
HashScanOpaque so = (HashScanOpaque ) scan -> opaque ;
477
477
Relation rel = scan -> indexRelation ;
478
478
479
- /* Before leaving current page, deal with any killed items */
479
+ /*
480
+ * Before leaving current page, deal with any killed items.
481
+ * Also, ensure that we acquire lock on current page before
482
+ * calling _hash_kill_items.
483
+ */
480
484
if (so -> numKilled > 0 )
485
+ {
486
+ LockBuffer (so -> hashso_curbuf , BUFFER_LOCK_SHARE );
481
487
_hash_kill_items (scan );
488
+ LockBuffer (so -> hashso_curbuf , BUFFER_LOCK_UNLOCK );
489
+ }
482
490
483
491
_hash_dropscanbuf (rel , so );
484
492
@@ -507,9 +515,17 @@ hashendscan(IndexScanDesc scan)
507
515
HashScanOpaque so = (HashScanOpaque ) scan -> opaque ;
508
516
Relation rel = scan -> indexRelation ;
509
517
510
- /* Before leaving current page, deal with any killed items */
518
+ /*
519
+ * Before leaving current page, deal with any killed items.
520
+ * Also, ensure that we acquire lock on current page before
521
+ * calling _hash_kill_items.
522
+ */
511
523
if (so -> numKilled > 0 )
524
+ {
525
+ LockBuffer (so -> hashso_curbuf , BUFFER_LOCK_SHARE );
512
526
_hash_kill_items (scan );
527
+ LockBuffer (so -> hashso_curbuf , BUFFER_LOCK_UNLOCK );
528
+ }
513
529
514
530
_hash_dropscanbuf (rel , so );
515
531
0 commit comments