forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitcbfbb14
committed
Avoid deadlock during orphan temp table removal.
If temp tables have dependencies (such as sequences) then it'spossible for autovacuum's cleanup of orphan temp tables to deadlockagainst an incoming backend that's trying to clean out the tempnamespace for its own use. That can happen because RemoveTempRelations'performDeletion call can visit objects within the namespace inan order different from the order in which a per-table deletionwill visit them.To fix, observe that performDeletion will begin by taking an exclusivelock 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'renot running concurrently with RemoveTempRelations, while also notconflicting with ordinary use of the namespace. This requiresintroducing a conditional version of LockDatabaseObject, but that's nobig deal. (It's surprising we've got along without that this long.)Report and patch by Mikhail Zhilin. Back-patch to all supportedbranches.Discussion:https://postgr.es/m/c43ce028-2bc2-4865-9b89-3f706246eed5@postgrespro.ru1 parent3235a11 commitcbfbb14
File tree
3 files changed
+60
-1
lines changed- src
- backend
- postmaster
- storage/lmgr
- include/storage
3 files changed
+60
-1
lines changedLines changed: 20 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
76 | 76 |
| |
77 | 77 |
| |
78 | 78 |
| |
| 79 | + | |
79 | 80 |
| |
80 | 81 |
| |
81 | 82 |
| |
| |||
2329 | 2330 |
| |
2330 | 2331 |
| |
2331 | 2332 |
| |
| 2333 | + | |
| 2334 | + | |
| 2335 | + | |
| 2336 | + | |
| 2337 | + | |
| 2338 | + | |
| 2339 | + | |
| 2340 | + | |
| 2341 | + | |
| 2342 | + | |
| 2343 | + | |
| 2344 | + | |
| 2345 | + | |
| 2346 | + | |
| 2347 | + | |
| 2348 | + | |
| 2349 | + | |
| 2350 | + | |
2332 | 2351 |
| |
2333 | 2352 |
| |
2334 | 2353 |
| |
| |||
2346 | 2365 |
| |
2347 | 2366 |
| |
2348 | 2367 |
| |
2349 |
| - | |
| 2368 | + | |
2350 | 2369 |
| |
2351 | 2370 |
| |
2352 | 2371 |
| |
|
Lines changed: 38 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1019 | 1019 |
| |
1020 | 1020 |
| |
1021 | 1021 |
| |
| 1022 | + | |
| 1023 | + | |
| 1024 | + | |
| 1025 | + | |
| 1026 | + | |
| 1027 | + | |
| 1028 | + | |
| 1029 | + | |
| 1030 | + | |
| 1031 | + | |
| 1032 | + | |
| 1033 | + | |
| 1034 | + | |
| 1035 | + | |
| 1036 | + | |
| 1037 | + | |
| 1038 | + | |
| 1039 | + | |
| 1040 | + | |
| 1041 | + | |
| 1042 | + | |
| 1043 | + | |
| 1044 | + | |
| 1045 | + | |
| 1046 | + | |
| 1047 | + | |
| 1048 | + | |
| 1049 | + | |
| 1050 | + | |
| 1051 | + | |
| 1052 | + | |
| 1053 | + | |
| 1054 | + | |
| 1055 | + | |
| 1056 | + | |
| 1057 | + | |
| 1058 | + | |
| 1059 | + | |
1022 | 1060 |
| |
1023 | 1061 |
| |
1024 | 1062 |
| |
|
Lines changed: 2 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
93 | 93 |
| |
94 | 94 |
| |
95 | 95 |
| |
| 96 | + | |
| 97 | + | |
96 | 98 |
| |
97 | 99 |
| |
98 | 100 |
| |
|
0 commit comments
Comments
(0)