0001-Acquire-super-exclusive-lock-in-lazy_vacuum_heap_rel.patch

application/octet-stream

Filename: 0001-Acquire-super-exclusive-lock-in-lazy_vacuum_heap_rel.patch
Type: application/octet-stream
Part: 0
Message: Re: PANIC: wrong buffer passed to visibilitymap_clear

Patch

Format: format-patch
Series: patch 0001
Subject: Acquire super-exclusive lock in lazy_vacuum_heap_rel() again.
File+
src/backend/access/heap/vacuumlazy.c 7 3
From 8bc3c86f71a7a2b31faecd5a203747a511f3054e Mon Sep 17 00:00:00 2001
From: Peter Geoghegan <pg@bowt.ie>
Date: Sun, 11 Apr 2021 08:39:45 -0700
Subject: [PATCH] Acquire super-exclusive lock in lazy_vacuum_heap_rel() again.

---
 src/backend/access/heap/vacuumlazy.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/backend/access/heap/vacuumlazy.c b/src/backend/access/heap/vacuumlazy.c
index f592e71364..94880ed054 100644
--- a/src/backend/access/heap/vacuumlazy.c
+++ b/src/backend/access/heap/vacuumlazy.c
@@ -2296,7 +2296,12 @@ lazy_vacuum_heap_rel(LVRelState *vacrel)
 		vacrel->blkno = tblk;
 		buf = ReadBufferExtended(vacrel->rel, MAIN_FORKNUM, tblk, RBM_NORMAL,
 								 vacrel->bstrategy);
-		LockBuffer(buf, BUFFER_LOCK_EXCLUSIVE);
+		if (!ConditionalLockBufferForCleanup(buf))
+		{
+			ReleaseBuffer(buf);
+			++tupindex;
+			continue;
+		}
 		tupindex = lazy_vacuum_heap_page(vacrel, tblk, buf, tupindex,
 										 &vmbuffer);
 
@@ -2339,8 +2344,7 @@ lazy_vacuum_heap_rel(LVRelState *vacrel)
  *	lazy_vacuum_heap_page() -- free page's LP_DEAD items listed in the
  *						  vacrel->dead_tuples array.
  *
- * Caller must have an exclusive buffer lock on the buffer (though a
- * super-exclusive lock is also acceptable).
+ * Caller must hold pin and buffer cleanup lock on the buffer.
  *
  * tupindex is the index in vacrel->dead_tuples of the first dead tuple for
  * this page.  We assume the rest follow sequentially.  The return value is
-- 
2.29.2