forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitc66a7d7
committed
Handle DROP DATABASE getting interrupted
Until now, when DROP DATABASE got interrupted in the wrong moment, the removalof the pg_database row would also roll back, even though some irreversiblesteps have already been taken. E.g. DropDatabaseBuffers() might have thrownout dirty buffers, or files could have been unlinked. But we continued toallow connections to such a corrupted database.To fix this, mark databases invalid with an in-place update, just beforestarting to perform irreversible steps. As we can't add a new column in theback branches, we use pg_database.datconnlimit = -2 for this purpose.An invalid database cannot be connected to anymore, but can still bedropped.Unfortunately we can't easily add output to psql's \l to indicate that somedatabase is invalid, it doesn't fit in any of the existing columns.Add tests verifying that a interrupted DROP DATABASE is handled correctly inthe backend and in various tools.Reported-by: Evgeny Morozov <postgresql3@realityexists.net>Author: Andres Freund <andres@anarazel.de>Reviewed-by: Daniel Gustafsson <daniel@yesql.se>Reviewed-by: Thomas Munro <thomas.munro@gmail.com>Discussion:https://postgr.es/m/20230509004637.cgvmfwrbht7xm7p6@awork3.anarazel.deDiscussion:https://postgr.es/m/20230314174521.74jl6ffqsee5mtug@awork3.anarazel.deBackpatch: 11-, bug present in all supported versions1 parent83ecfa9 commitc66a7d7
File tree
20 files changed
+421
-28
lines changed- doc/src/sgml
- src
- backend
- commands
- postmaster
- utils/init
- bin
- pg_amcheck
- t
- pg_dump
- t
- pg_upgrade/t
- scripts
- t
- include/catalog
- test/recovery
- t
20 files changed
+421
-28
lines changedLines changed: 2 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3042 | 3042 |
| |
3043 | 3043 |
| |
3044 | 3044 |
| |
3045 |
| - | |
| 3045 | + | |
| 3046 | + | |
3046 | 3047 |
| |
3047 | 3048 |
| |
3048 | 3049 |
| |
|
Lines changed: 90 additions & 20 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
719 | 719 |
| |
720 | 720 |
| |
721 | 721 |
| |
722 |
| - | |
| 722 | + | |
723 | 723 |
| |
724 | 724 |
| |
725 | 725 |
| |
| |||
926 | 926 |
| |
927 | 927 |
| |
928 | 928 |
| |
929 |
| - | |
| 929 | + | |
930 | 930 |
| |
931 | 931 |
| |
932 | 932 |
| |
| |||
977 | 977 |
| |
978 | 978 |
| |
979 | 979 |
| |
| 980 | + | |
| 981 | + | |
| 982 | + | |
| 983 | + | |
| 984 | + | |
| 985 | + | |
| 986 | + | |
| 987 | + | |
| 988 | + | |
| 989 | + | |
980 | 990 |
| |
981 | 991 |
| |
982 | 992 |
| |
| |||
1576 | 1586 |
| |
1577 | 1587 |
| |
1578 | 1588 |
| |
| 1589 | + | |
1579 | 1590 |
| |
1580 | 1591 |
| |
1581 | 1592 |
| |
| |||
1691 | 1702 |
| |
1692 | 1703 |
| |
1693 | 1704 |
| |
1694 |
| - | |
1695 |
| - | |
1696 |
| - | |
1697 |
| - | |
1698 |
| - | |
1699 |
| - | |
1700 |
| - | |
1701 |
| - | |
1702 |
| - | |
1703 |
| - | |
1704 |
| - | |
1705 | 1705 |
| |
1706 | 1706 |
| |
1707 | 1707 |
| |
| |||
1718 | 1718 |
| |
1719 | 1719 |
| |
1720 | 1720 |
| |
| 1721 | + | |
| 1722 | + | |
| 1723 | + | |
| 1724 | + | |
| 1725 | + | |
| 1726 | + | |
| 1727 | + | |
| 1728 | + | |
| 1729 | + | |
| 1730 | + | |
| 1731 | + | |
| 1732 | + | |
| 1733 | + | |
| 1734 | + | |
| 1735 | + | |
| 1736 | + | |
| 1737 | + | |
| 1738 | + | |
| 1739 | + | |
| 1740 | + | |
| 1741 | + | |
| 1742 | + | |
| 1743 | + | |
| 1744 | + | |
| 1745 | + | |
| 1746 | + | |
| 1747 | + | |
| 1748 | + | |
| 1749 | + | |
| 1750 | + | |
| 1751 | + | |
1721 | 1752 |
| |
1722 | 1753 |
| |
1723 | 1754 |
| |
| |||
1730 | 1761 |
| |
1731 | 1762 |
| |
1732 | 1763 |
| |
1733 |
| - | |
1734 |
| - | |
1735 |
| - | |
1736 |
| - | |
1737 |
| - | |
1738 | 1764 |
| |
1739 | 1765 |
| |
1740 | 1766 |
| |
| |||
2248 | 2274 |
| |
2249 | 2275 |
| |
2250 | 2276 |
| |
2251 |
| - | |
| 2277 | + | |
2252 | 2278 |
| |
2253 | 2279 |
| |
2254 | 2280 |
| |
| |||
2319 | 2345 |
| |
2320 | 2346 |
| |
2321 | 2347 |
| |
2322 |
| - | |
| 2348 | + | |
2323 | 2349 |
| |
2324 | 2350 |
| |
2325 | 2351 |
| |
| |||
2346 | 2372 |
| |
2347 | 2373 |
| |
2348 | 2374 |
| |
| 2375 | + | |
| 2376 | + | |
| 2377 | + | |
| 2378 | + | |
| 2379 | + | |
| 2380 | + | |
| 2381 | + | |
| 2382 | + | |
2349 | 2383 |
| |
2350 | 2384 |
| |
2351 | 2385 |
| |
| |||
3064 | 3098 |
| |
3065 | 3099 |
| |
3066 | 3100 |
| |
| 3101 | + | |
| 3102 | + | |
| 3103 | + | |
| 3104 | + | |
| 3105 | + | |
| 3106 | + | |
| 3107 | + | |
| 3108 | + | |
| 3109 | + | |
| 3110 | + | |
| 3111 | + | |
| 3112 | + | |
| 3113 | + | |
| 3114 | + | |
| 3115 | + | |
| 3116 | + | |
| 3117 | + | |
| 3118 | + | |
| 3119 | + | |
| 3120 | + | |
| 3121 | + | |
| 3122 | + | |
| 3123 | + | |
| 3124 | + | |
| 3125 | + | |
| 3126 | + | |
| 3127 | + | |
| 3128 | + | |
| 3129 | + | |
| 3130 | + | |
| 3131 | + | |
| 3132 | + | |
| 3133 | + | |
| 3134 | + | |
| 3135 | + | |
| 3136 | + | |
3067 | 3137 |
| |
3068 | 3138 |
| |
3069 | 3139 |
| |
|
Lines changed: 14 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1850 | 1850 |
| |
1851 | 1851 |
| |
1852 | 1852 |
| |
| 1853 | + | |
| 1854 | + | |
| 1855 | + | |
| 1856 | + | |
| 1857 | + | |
| 1858 | + | |
| 1859 | + | |
| 1860 | + | |
| 1861 | + | |
| 1862 | + | |
| 1863 | + | |
| 1864 | + | |
| 1865 | + | |
| 1866 | + | |
1853 | 1867 |
| |
1854 | 1868 |
| |
1855 | 1869 |
| |
|
Lines changed: 12 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1972 | 1972 |
| |
1973 | 1973 |
| |
1974 | 1974 |
| |
| 1975 | + | |
| 1976 | + | |
| 1977 | + | |
| 1978 | + | |
| 1979 | + | |
| 1980 | + | |
| 1981 | + | |
| 1982 | + | |
| 1983 | + | |
| 1984 | + | |
| 1985 | + | |
| 1986 | + | |
1975 | 1987 |
| |
1976 | 1988 |
| |
1977 | 1989 |
| |
|
Lines changed: 10 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1116 | 1116 |
| |
1117 | 1117 |
| |
1118 | 1118 |
| |
| 1119 | + | |
1119 | 1120 |
| |
1120 | 1121 |
| |
1121 | 1122 |
| |
| |||
1125 | 1126 |
| |
1126 | 1127 |
| |
1127 | 1128 |
| |
| 1129 | + | |
| 1130 | + | |
| 1131 | + | |
| 1132 | + | |
| 1133 | + | |
| 1134 | + | |
| 1135 | + | |
| 1136 | + | |
| 1137 | + | |
1128 | 1138 |
| |
1129 | 1139 |
| |
1130 | 1140 |
| |
|
Lines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1590 | 1590 |
| |
1591 | 1591 |
| |
1592 | 1592 |
| |
1593 |
| - | |
| 1593 | + | |
1594 | 1594 |
| |
1595 | 1595 |
| |
1596 | 1596 |
| |
|
Lines changed: 34 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
291 | 291 |
| |
292 | 292 |
| |
293 | 293 |
| |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
294 | 328 |
| |
295 | 329 |
| |
296 | 330 |
| |
|
Lines changed: 2 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1345 | 1345 |
| |
1346 | 1346 |
| |
1347 | 1347 |
| |
1348 |
| - | |
| 1348 | + | |
1349 | 1349 |
| |
1350 | 1350 |
| |
1351 | 1351 |
| |
| |||
1488 | 1488 |
| |
1489 | 1489 |
| |
1490 | 1490 |
| |
1491 |
| - | |
| 1491 | + | |
1492 | 1492 |
| |
1493 | 1493 |
| |
1494 | 1494 |
| |
|
Lines changed: 19 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1907 | 1907 |
| |
1908 | 1908 |
| |
1909 | 1909 |
| |
| 1910 | + | |
| 1911 | + | |
| 1912 | + | |
| 1913 | + | |
| 1914 | + | |
| 1915 | + | |
| 1916 | + | |
| 1917 | + | |
| 1918 | + | |
| 1919 | + | |
| 1920 | + | |
1910 | 1921 |
| |
1911 | 1922 |
| |
1912 | 1923 |
| |
| |||
4690 | 4701 |
| |
4691 | 4702 |
| |
4692 | 4703 |
| |
| 4704 | + | |
| 4705 | + | |
| 4706 | + | |
| 4707 | + | |
| 4708 | + | |
| 4709 | + | |
| 4710 | + | |
| 4711 | + | |
4693 | 4712 |
| |
4694 | 4713 |
| |
4695 | 4714 |
| |
|
0 commit comments
Comments
(0)