postgresql/src/backend/postmaster
Tom Lane 6faca9ae28 Avoid deadlock during orphan temp table removal.
If temp tables have dependencies (such as sequences) then it's
possible for autovacuum's cleanup of orphan temp tables to deadlock
against an incoming backend that's trying to clean out the temp
namespace for its own use.  That can happen because RemoveTempRelations'
performDeletion call can visit objects within the namespace in
an order different from the order in which a per-table deletion
will visit them.

To fix, observe that performDeletion will begin by taking an exclusive
lock on the temp namespace (even though it won't actually delete it).
So, if we can get a shared lock on the namespace, we can be sure we're
not running concurrently with RemoveTempRelations, while also not
conflicting with ordinary use of the namespace.  This requires
introducing a conditional version of LockDatabaseObject, but that's no
big deal.  (It's surprising we've got along without that this long.)

Report and patch by Mikhail Zhilin.  Back-patch to all supported
branches.

Discussion: https://postgr.es/m/c43ce028-2bc2-4865-9b89-3f706246eed5@postgrespro.ru
2024-04-02 14:59:32 -04:00
..
autovacuum.c Avoid deadlock during orphan temp table removal. 2024-04-02 14:59:32 -04:00
auxprocess.c Refactor postmaster child process launching 2024-03-18 11:35:30 +02:00
bgworker.c Refactor postmaster child process launching 2024-03-18 11:35:30 +02:00
bgwriter.c Refactor postmaster child process launching 2024-03-18 11:35:30 +02:00
checkpointer.c Refactor postmaster child process launching 2024-03-18 11:35:30 +02:00
fork_process.c Update copyright for 2024 2024-01-03 20:49:05 -05:00
interrupt.c Centralize logic for restoring errno in signal handlers. 2024-02-14 16:34:18 -06:00
launch_backend.c Remove assertions that some compiler say are tautological 2024-03-20 09:14:51 +02:00
Makefile Move some functions from postmaster.c to a new source file 2024-03-18 11:35:05 +02:00
meson.build Move some functions from postmaster.c to a new source file 2024-03-18 11:35:05 +02:00
pgarch.c Refactor postmaster child process launching 2024-03-18 11:35:30 +02:00
postmaster.c Move code for backend startup to separate file 2024-03-18 11:38:10 +02:00
startup.c Refactor postmaster child process launching 2024-03-18 11:35:30 +02:00
syslogger.c Avoid function call overhead of pg_popcount() in syslogger.c. 2024-04-02 10:32:49 -05:00
walsummarizer.c Avoid overflow in MaybeRemoveOldWalSummaries(). 2024-03-20 13:31:58 -05:00
walwriter.c Refactor postmaster child process launching 2024-03-18 11:35:30 +02:00