forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit6d0eb38

Amit Kapila
Fix deadlock for multiple replicating truncates of the same table.
While applying the truncate change, the logical apply worker acquiresRowExclusiveLock on the relation being truncated. This allowed truncate onthe relation at a time by two apply workers which lead to a deadlock. Thereason was that one of the workers after updating the pg_class tuple triesto acquire SHARE lock on the relation and started to wait for the secondworker which has acquired RowExclusiveLock on the relation. And when thesecond worker tries to update the pg_class tuple, it starts to wait forthe first worker which leads to a deadlock. Fix it by acquiringAccessExclusiveLock on the relation before applying the truncate change aswe do for normal truncate operation.Author: Peter Smith, test case by Haiying TangReviewed-by: Dilip Kumar, Amit KapilaBackpatch-through: 11Discussion:https://postgr.es/m/CAHut+PsNm43p0jM+idTvWwiGZPcP0hGrHMPK9TOAkc+a4UpUqw@mail.gmail.com1 parentf21fada commit6d0eb38
File tree
2 files changed
+61
-5
lines changed- src
- backend/replication/logical
- test/subscription/t
2 files changed
+61
-5
lines changedLines changed: 5 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1818 | 1818 |
| |
1819 | 1819 |
| |
1820 | 1820 |
| |
| 1821 | + | |
1821 | 1822 |
| |
1822 | 1823 |
| |
1823 | 1824 |
| |
| |||
1831 | 1832 |
| |
1832 | 1833 |
| |
1833 | 1834 |
| |
1834 |
| - | |
| 1835 | + | |
1835 | 1836 |
| |
1836 | 1837 |
| |
1837 | 1838 |
| |
1838 | 1839 |
| |
1839 | 1840 |
| |
1840 | 1841 |
| |
1841 |
| - | |
| 1842 | + | |
1842 | 1843 |
| |
1843 | 1844 |
| |
1844 | 1845 |
| |
| |||
1856 | 1857 |
| |
1857 | 1858 |
| |
1858 | 1859 |
| |
1859 |
| - | |
| 1860 | + | |
1860 | 1861 |
| |
1861 | 1862 |
| |
1862 | 1863 |
| |
| |||
1876 | 1877 |
| |
1877 | 1878 |
| |
1878 | 1879 |
| |
1879 |
| - | |
| 1880 | + | |
1880 | 1881 |
| |
1881 | 1882 |
| |
1882 | 1883 |
| |
|
Lines changed: 56 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
6 | 6 |
| |
7 | 7 |
| |
8 | 8 |
| |
9 |
| - | |
| 9 | + | |
10 | 10 |
| |
11 | 11 |
| |
12 | 12 |
| |
| |||
16 | 16 |
| |
17 | 17 |
| |
18 | 18 |
| |
| 19 | + | |
| 20 | + | |
19 | 21 |
| |
20 | 22 |
| |
21 | 23 |
| |
| |||
187 | 189 |
| |
188 | 190 |
| |
189 | 191 |
| |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + |
0 commit comments
Comments
(0)