From 2a912bc1abdbaa2f73555cf2c71bb4c401aa515b Mon Sep 17 00:00:00 2001 From: Noah Misch Date: Tue, 29 Oct 2024 09:39:55 -0700 Subject: Unpin buffer before inplace update waits for an XID to end. Commit a07e03fd8fa7daf4d1356f7cb501ffe784ea6257 changed inplace updates to wait for heap_update() commands like GRANT TABLE and GRANT DATABASE. By keeping the pin during that wait, a sequence of autovacuum workers and an uncommitted GRANT starved one foreground LockBufferForCleanup() for six minutes, on buildfarm member sarus. Prevent, at the cost of a bit of complexity. Back-patch to v12, like the earlier commit. That commit and heap_inplace_lock() have not yet appeared in any release. Discussion: https://postgr.es/m/20241026184936.ae.nmisch@google.com --- src/include/access/heapam.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/include/access/heapam.h') diff --git a/src/include/access/heapam.h b/src/include/access/heapam.h index 9c06d754e33..be58b16efae 100644 --- a/src/include/access/heapam.h +++ b/src/include/access/heapam.h @@ -158,7 +158,8 @@ extern TM_Result heap_lock_tuple(Relation relation, HeapTuple tuple, Buffer *buffer, struct TM_FailureData *tmfd); extern bool heap_inplace_lock(Relation relation, - HeapTuple oldtup_ptr, Buffer buffer); + HeapTuple oldtup_ptr, Buffer buffer, + void (*release_callback) (void *), void *arg); extern void heap_inplace_update_and_unlock(Relation relation, HeapTuple oldtup, HeapTuple tuple, Buffer buffer); -- cgit v1.2.3