postgresql/src/backend
Tom Lane f5d9212e53 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
..
access Promote assertion about !ReindexIsProcessingIndex to runtime error. 2024-02-25 16:15:07 -05:00
bootstrap Revert "Skip WAL for new relfilenodes, under wal_level=minimal." 2020-03-22 09:24:13 -07:00
catalog Fix confusion about the return rowtype of SQL-language procedures. 2024-03-12 18:16:10 -04:00
commands Fix failure of ALTER FOREIGN TABLE SET SCHEMA to move sequences. 2024-03-26 15:28:16 -04:00
executor Fix unnecessary use of moving-aggregate mode with non-moving frame. 2024-03-27 13:39:03 -04:00
foreign Update copyright for 2019 2019-01-02 12:44:25 -05:00
jit Track LLVM 18 changes. 2024-01-25 13:47:35 +13:00
lib Fix lock assertions in dshash.c. 2022-07-11 15:51:47 +12:00
libpq Disconnect if socket cannot be put into non-blocking mode 2024-03-12 10:18:54 +02:00
main Fix outdated --help message for postgres -f 2022-08-15 13:37:42 +09:00
nodes Further fixes for MULTIEXPR_SUBLINK fix. 2022-09-06 16:38:18 -04:00
optimizer Fix confusion about the return rowtype of SQL-language procedures. 2024-03-12 18:16:10 -04:00
parser Make INSERT-from-multiple-VALUES-rows handle domain target columns. 2024-03-14 14:57:16 -04:00
partitioning Fix incorrect pruning of NULL partition for boolean IS NOT clauses 2024-02-20 12:51:38 +13:00
po Translation updates 2024-02-05 14:52:35 +01:00
port Close socket in case of errors in setting non-blocking 2024-01-17 11:24:11 +01:00
postmaster Avoid deadlock during orphan temp table removal. 2024-04-02 14:59:04 -04:00
regex Avoid character classification in regex escape parsing. 2023-04-21 08:21:04 -07:00
replication Revert "Skip .DS_Store files in server side utils" 2024-02-13 14:08:56 +01:00
rewrite Make INSERT-from-multiple-VALUES-rows handle domain target columns. 2024-03-14 14:57:16 -04:00
snowball In the Snowball dictionary, don't try to stem excessively-long words. 2022-08-31 10:42:05 -04:00
statistics Fix incorrectly reported stats kind in "can't happen" ERROR 2024-03-05 16:19:26 +13:00
storage Avoid deadlock during orphan temp table removal. 2024-04-02 14:59:04 -04:00
tcop Be more rigorous about local variables in PostgresMain(). 2023-07-10 12:14:34 -04:00
tsearch Limit to_tsvector_byid's initial array allocation to something sane. 2023-09-25 11:50:28 -04:00
utils Allow "make check"-style testing to work with musl C library. 2024-03-26 11:44:49 -04:00
.gitignore Add .gitignore entries for AIX-specific intermediate build artifacts. 2015-07-08 20:44:22 -04:00
common.mk Remove PARTIAL_LINKING build mode. 2018-03-30 17:33:04 -07:00
Makefile Get rid of jsonpath_gram.h and jsonpath_scanner.h 2019-03-20 11:13:34 +03:00
nls.mk Translation updates 2020-08-10 15:21:18 +02:00