From 449f67324384d01d0e9601362f49bbe5b25f2676 Mon Sep 17 00:00:00 2001 From: Melanie Plageman Date: Wed, 27 Aug 2025 08:50:15 -0400 Subject: [PATCH v7 01/22] Remove unneeded VM pin from VM replay During replay of an operation setting bits in the visibility map, XLogReadBufferForRedoExtended() will return a pinned buffer containing the specified block of the visibility map. It will also be sure to create the visibility map if it doesn't exist. Previously, heap_xlog_visible() called visibilitymap_pin() even after getting a buffer in this way. This would just have resulted in visibilitymap_pin() returning early since the specified page was already present and pinned. Thus, it wouldn't have resulted in another pin and we can just eliminate this call to visibilitymap_pin(). Inspired by a related report by Kirill Reshke on an in-progress patch. Discussion: https://postgr.es/m/CALdSSPhAU56g1gGVT0%2BwG8RrSWE6qW8TOfNJS1HNAWX6wPgbFA%40mail.gmail.com --- src/backend/access/heap/heapam_xlog.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backend/access/heap/heapam_xlog.c b/src/backend/access/heap/heapam_xlog.c index eb4bd3d6ae3..e3e021f2bdd 100644 --- a/src/backend/access/heap/heapam_xlog.c +++ b/src/backend/access/heap/heapam_xlog.c @@ -295,8 +295,8 @@ heap_xlog_visible(XLogReaderState *record) LockBuffer(vmbuffer, BUFFER_LOCK_UNLOCK); reln = CreateFakeRelcacheEntry(rlocator); - visibilitymap_pin(reln, blkno, &vmbuffer); + Assert(visibilitymap_pin_ok(blkno, vmbuffer)); visibilitymap_set(reln, blkno, InvalidBuffer, lsn, vmbuffer, xlrec->snapshotConflictHorizon, vmbits); -- 2.43.0