*** a/src/backend/access/nbtree/README
--- b/src/backend/access/nbtree/README
***************
*** 404,415 **** that this breaks the interlock between VACUUM and indexscans, but that is
  not so: as long as an indexscanning process has a pin on the page where
  the index item used to be, VACUUM cannot complete its btbulkdelete scan
  and so cannot remove the heap tuple.  This is another reason why
! btbulkdelete has to get super-exclusive lock on every leaf page, not only
! the ones where it actually sees items to delete.  To handle the cases
! where it is safe to release the pin after reading the index page, the LSN
! of the index page is read along with the index entries before the shared
! lock is released, and we do not attempt to flag index tuples as dead if
! the page is not pinned and the LSN does not match.
  
  WAL Considerations
  ------------------
--- 404,415 ----
  not so: as long as an indexscanning process has a pin on the page where
  the index item used to be, VACUUM cannot complete its btbulkdelete scan
  and so cannot remove the heap tuple.  This is another reason why
! btbulkdelete has to get a super-exclusive lock on every leaf page, not
! only the ones where it actually sees items to delete.  So that we can
! handle the cases where we attempt LP_DEAD flagging for a page after we
! have released its pin, we remember the LSN of the index page when we read
! the index tuples from it; we do not attempt to flag index tuples as dead
! if the we didn't hold the pin the entire time and the LSN has changed.
  
  WAL Considerations
  ------------------
*** a/src/backend/access/nbtree/nbtutils.c
--- b/src/backend/access/nbtree/nbtutils.c
***************
*** 1770,1776 **** _bt_killitems(IndexScanDesc scan)
  
  	if (BTScanPosIsPinned(so->currPos))
  	{
! 		/* The buffer is still pinned, but not locked.  Lock it now. */
  		LockBuffer(so->currPos.buf, BT_READ);
  
  		page = BufferGetPage(so->currPos.buf);
--- 1770,1781 ----
  
  	if (BTScanPosIsPinned(so->currPos))
  	{
! 		/*
! 		 * We have held the pin on this page since we read the index tuples,
! 		 * so all we need to do is lock it.  The pin will have prevented
! 		 * re-use of any TID on the page, so there is no need to check the
! 		 * LSN.
! 		 */
  		LockBuffer(so->currPos.buf, BT_READ);
  
  		page = BufferGetPage(so->currPos.buf);
