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 <[email protected]>
Reported-by: Andrey Borodin <[email protected]>
Reviewed-by: Andrey Borodin <[email protected]>
Discussion: https://postgr.es/m/[email protected]
Discussion: 
https://postgr.es/m/cahg+qdf3ncb3voaqq5efcv5dyyuz9sncsjau-x1jdbtcjk3...@mail.gmail.com
Discussion: 
https://postgr.es/m/[email protected]
Backpatch-through: 17

Branch
------
REL_17_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/5897bd1d8d36cb45523d0ac20da734398b7e4b16

Modified Files
--------------
src/backend/access/heap/pruneheap.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

Reply via email to