postgresql/src/include/storage
Tom Lane 4fb56a734d 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:04 -04:00
..
.gitignore When trace_lwlocks is used, identify individual lwlocks by name. 2015-09-11 14:01:39 -04:00
backendid.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
barrier.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
block.h Remove some pointless code in block.h. 2022-03-03 19:15:38 -05:00
buf.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
buf_internals.h Ensure we use the correct spelling of "ensure" 2023-11-10 00:17:07 +13:00
buffile.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
bufmgr.h Apply PGDLLIMPORT markings broadly. 2022-04-08 08:16:38 -04:00
bufpage.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
checksum.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
checksum_impl.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
condition_variable.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
copydir.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
dsm.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
dsm_impl.h Apply PGDLLIMPORT markings broadly. 2022-04-08 08:16:38 -04:00
fd.h Revert recent changes with durable_rename_excl() 2022-04-28 13:08:16 +09:00
fileset.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
freespace.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
fsm_internals.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
indexfsm.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
ipc.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
item.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
itemid.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
itemptr.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
large_object.h Apply PGDLLIMPORT markings broadly. 2022-04-08 08:16:38 -04:00
latch.h Pre-beta mechanical code beautification. 2022-05-12 15:17:30 -04:00
lmgr.h Avoid deadlock during orphan temp table removal. 2024-04-02 14:59:04 -04:00
lock.h Apply PGDLLIMPORT markings broadly. 2022-04-08 08:16:38 -04:00
lockdefs.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
lwlock.h lwlock: Fix quadratic behavior with very long wait lists 2024-01-18 11:12:31 +09:00
md.h Rethink PROCSIGNAL_BARRIER_SMGRRELEASE. 2022-05-07 16:32:10 +12:00
off.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
pg_sema.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
pg_shmem.h Apply PGDLLIMPORT markings broadly. 2022-04-08 08:16:38 -04:00
pmsignal.h Apply PGDLLIMPORT markings broadly. 2022-04-08 08:16:38 -04:00
predicate.h Apply PGDLLIMPORT markings broadly. 2022-04-08 08:16:38 -04:00
predicate_internals.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
proc.h lwlock: Fix quadratic behavior with very long wait lists 2024-01-18 11:12:31 +09:00
procarray.h Improve heuristics for compressing the KnownAssignedXids array. 2022-11-29 15:43:17 -05:00
proclist.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
proclist_types.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
procsignal.h Fix DROP {DATABASE,TABLESPACE} on Windows. 2022-02-12 10:21:23 +13:00
reinit.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
relfilenode.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
s_lock.h Allow use of __sync_lock_test_and_set for spinlocks on any machine. 2022-11-02 17:37:26 -04:00
sharedfileset.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
shm_mq.h shm_mq_sendv: Fix flushing bug when receiver not yet attached. 2022-05-31 08:46:54 -04:00
shm_toc.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
shmem.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
sinval.h Apply PGDLLIMPORT markings broadly. 2022-04-08 08:16:38 -04:00
sinvaladt.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
smgr.h Rethink PROCSIGNAL_BARRIER_SMGRRELEASE. 2022-05-07 16:32:10 +12:00
spin.h Apply PGDLLIMPORT markings broadly. 2022-04-08 08:16:38 -04:00
standby.h Apply PGDLLIMPORT markings broadly. 2022-04-08 08:16:38 -04:00
standbydefs.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
sync.h Update copyright for 2022 2022-01-07 19:04:57 -05:00