From 8ea3610c68f78ba902a0ef0ac71226e300f5dc6e Mon Sep 17 00:00:00 2001 From: Melanie Plageman Date: Mon, 21 Sep 2026 11:21:57 -0400 Subject: [PATCH v2 2/4] Avoid replay cleanup locks for freeze-only and VM-only records 6dbb490261a combined pruning and freezing in a single WAL record but unconditionally requested a cleanup lock during replay. Prior to version 17, freeze-only records were replayed under an ordinary exclusive lock. 1252a4ee286 subsequently folded visibility map updates into the same records, extending the unnecessary cleanup-lock requirement to VM-only updates starting in version 19. Request a cleanup lock in redo only when the record actually prunes. Freezing and visibility updates do not move or remove tuple storage, so they need not wait for other buffer pins to be released. This avoids unnecessary replay delays and cancellation of standby queries holding buffer pins. The fix is the same for all versions, though it addresses two oversights in master/19 and one in 18/17. Reported-by: Satyanarayana Narlapuram Reported-by: Andrey Borodin Reviewed-by: Andrey Borodin Discussion: https://postgr.es/m/85b6968b-49f2-4243-86a6-9b4116e6439b@iki.fi Discussion: https://postgr.es/m/CAHg+QDf3NcB3vOAqQ5EFcV5DYYUZ9snCSJAU-x1JDbtcjK3eBQ@mail.gmail.com Discussion: https://postgr.es/m/F9BF304E-1298-481C-829A-B4E10AED025A@yandex-team.ru --- src/backend/access/heap/pruneheap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backend/access/heap/pruneheap.c b/src/backend/access/heap/pruneheap.c index 5778ba49a05..314b03b56f2 100644 --- a/src/backend/access/heap/pruneheap.c +++ b/src/backend/access/heap/pruneheap.c @@ -1337,7 +1337,7 @@ heap_page_prune_and_freeze(PruneFreezeParams *params, do_set_vm ? prstate.vmbuffer : InvalidBuffer, do_set_vm ? prstate.new_vmbits : 0, conflict_xid, - true, /* cleanup lock */ + do_prune, /* cleanup lock */ params->reason, prstate.frozen, prstate.nfrozen, prstate.redirected, prstate.nredirected, -- 2.43.0