From 866c6759a89c8f7b9f1ed05c4b8ce075f87f7ab7 Mon Sep 17 00:00:00 2001
From: Peter Geoghegan <pg@bowt.ie>
Date: Tue, 10 Jan 2023 16:14:39 -0800
Subject: [PATCH] Debug freeze map issue.

---
 src/backend/access/heap/heapam.c     | 2 ++
 src/backend/access/heap/vacuumlazy.c | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/src/backend/access/heap/heapam.c b/src/backend/access/heap/heapam.c
index 63c4f01f0..7a9e3c526 100644
--- a/src/backend/access/heap/heapam.c
+++ b/src/backend/access/heap/heapam.c
@@ -6281,6 +6281,7 @@ FreezeMultiXactId(MultiXactId multi, uint16 t_infomask,
 	if (!need_replace)
 		need_replace = MultiXactIdPrecedes(multi, cutoffs->MultiXactCutoff);
 
+#if 0
 	if (!need_replace)
 	{
 		/*
@@ -6295,6 +6296,7 @@ FreezeMultiXactId(MultiXactId multi, uint16 t_infomask,
 		pfree(members);
 		return multi;
 	}
+#endif
 
 	/*
 	 * Do a more thorough second pass over the multi to figure out which
diff --git a/src/backend/access/heap/vacuumlazy.c b/src/backend/access/heap/vacuumlazy.c
index a42e881da..11d548436 100644
--- a/src/backend/access/heap/vacuumlazy.c
+++ b/src/backend/access/heap/vacuumlazy.c
@@ -1168,6 +1168,8 @@ lazy_scan_heap(LVRelState *vacrel)
 			 * because setting the all-frozen bit doesn't cause recovery
 			 * conflicts.
 			 */
+			Assert(PageIsAllVisible(page));
+			Assert(VM_ALL_VISIBLE(vacrel->rel, blkno, &vmbuffer));
 			visibilitymap_set(vacrel->rel, blkno, buf, InvalidXLogRecPtr,
 							  vmbuffer, InvalidTransactionId,
 							  VISIBILITYMAP_ALL_FROZEN);
-- 
2.39.0

