0001-Assert-that-restart-behavior-happens-once-only.patch

application/octet-stream

Filename: 0001-Assert-that-restart-behavior-happens-once-only.patch
Type: application/octet-stream
Part: 0
Message: Re: pg14b1 stuck in lazy_scan_prune/heap_page_prune of pg_statistic

Patch

Format: format-patch
Series: patch 0001
Subject: Assert that restart behavior happens once only.
File+
src/backend/access/heap/vacuumlazy.c 5 0
From e58f592431c296a24fb91c34658a0885b73cd347 Mon Sep 17 00:00:00 2001
From: Peter Geoghegan <pg@bowt.ie>
Date: Tue, 8 Jun 2021 14:21:45 -0700
Subject: [PATCH] Assert that restart behavior happens once only.

---
 src/backend/access/heap/vacuumlazy.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/backend/access/heap/vacuumlazy.c b/src/backend/access/heap/vacuumlazy.c
index 4b600e951a..755ff62698 100644
--- a/src/backend/access/heap/vacuumlazy.c
+++ b/src/backend/access/heap/vacuumlazy.c
@@ -1698,6 +1698,7 @@ lazy_scan_prune(LVRelState *vacrel,
 	int			nfrozen;
 	OffsetNumber deadoffsets[MaxHeapTuplesPerPage];
 	xl_heap_freeze_tuple frozen[MaxHeapTuplesPerPage];
+	int			restarts = 0;
 
 	maxoff = PageGetMaxOffsetNumber(page);
 
@@ -1798,7 +1799,11 @@ retry:
 		res = HeapTupleSatisfiesVacuum(&tuple, vacrel->OldestXmin, buf);
 
 		if (unlikely(res == HEAPTUPLE_DEAD))
+		{
+			Assert(restarts == 0);
+			restarts++;
 			goto retry;
+		}
 
 		/*
 		 * The criteria for counting a tuple as live in this block need to
-- 
2.31.1