Back-patch b1ffe3ff into REL_13_STABLE.
authorThomas Munro <[email protected]>
Wed, 8 Jan 2025 21:03:10 +0000 (10:03 +1300)
committerThomas Munro <[email protected]>
Wed, 8 Jan 2025 21:14:11 +0000 (10:14 +1300)
commita722252ef1e1980fb697fe5cff7506245aec5f07
treea03b29db4abaf95382c77cae389b88fbd718db55
parent417d41c658b30bbfe8ef9db624e4a8125e6225d1
Back-patch b1ffe3ff into REL_13_STABLE.

This is a cherry pick of 4c8e00ae from the 14 branch into the 13 branch.

It avoids an assertion failure when ForwardSyncRequest() tries to
allocate memory while trying to compact the queue, if run in a critical
section.  RelationTruncate() gained a critical section in 38c579b0, and
could fail in that way in the 13 branch.

b1ffe3ff originally fixed the same problem with TruncateMultiXact(), but
for that case it only needed to go back as far as 14, where SLRUs
started using the sync request queue.  It also fixed a related deadlock
risk that doesn't apply in this case (this case doesn't wait), but it
might exist in theory and it doesn't hurt to keep the code the same as
later branches.

Author: Heikki Linnakangas <[email protected]> (original commit)
Reviewed-by: Michael Paquier <[email protected]> (in this new context)
Reported-by: Yura Sokolov <[email protected]>
Discussion: https://postgr.es/m/f98aaa79-80b5-47c9-832a-31416a3a528b%40postgrespro.ru
src/backend/access/transam/xlog.c
src/backend/postmaster/checkpointer.c