forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit086221c
committed
Prevent panic during shutdown checkpoint
When the checkpointer writes the shutdown checkpoint, it checksafterwards whether any WAL has been written since it started and throwsa PANIC if so. At that point, only walsenders are still active, so onemight think this could not happen, but walsenders can also generate WAL,for instance in BASE_BACKUP and certain variants ofCREATE_REPLICATION_SLOT. So they can trigger this panic if such acommand is run while the shutdown checkpoint is being written.To fix this, divide the walsender shutdown into two phases. First, thepostmaster sends a SIGUSR2 signal to all walsenders. The walsendersthen put themselves into the "stopping" state. In this state, theyreject any new commands. (For simplicity, we reject all new commands,so that in the future we do not have to track meticulously whichcommands might generate WAL.) The checkpointer waits for all walsendersto reach this state before proceeding with the shutdown checkpoint.After the shutdown checkpoint is done, the postmaster sendsSIGINT (previously unused) to the walsenders. This triggers theexisting shutdown behavior of sending out the shutdown checkpoint recordand then terminating.Author: Michael Paquier <michael.paquier@gmail.com>Reported-by: Fujii Masao <masao.fujii@gmail.com>1 parent499ae5f commit086221c
File tree
6 files changed
+141
-24
lines changed- doc/src/sgml
- src
- backend
- access/transam
- postmaster
- replication
- include/replication
6 files changed
+141
-24
lines changedLines changed: 5 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1690 | 1690 |
| |
1691 | 1691 |
| |
1692 | 1692 |
| |
| 1693 | + | |
| 1694 | + | |
| 1695 | + | |
| 1696 | + | |
| 1697 | + | |
1693 | 1698 |
| |
1694 | 1699 |
| |
1695 | 1700 |
| |
|
Lines changed: 6 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
8325 | 8325 |
| |
8326 | 8326 |
| |
8327 | 8327 |
| |
| 8328 | + | |
| 8329 | + | |
| 8330 | + | |
| 8331 | + | |
| 8332 | + | |
| 8333 | + | |
8328 | 8334 |
| |
8329 | 8335 |
| |
8330 | 8336 |
| |
|
Lines changed: 5 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2918 | 2918 |
| |
2919 | 2919 |
| |
2920 | 2920 |
| |
2921 |
| - | |
| 2921 | + | |
2922 | 2922 |
| |
2923 | 2923 |
| |
2924 | 2924 |
| |
| |||
3656 | 3656 |
| |
3657 | 3657 |
| |
3658 | 3658 |
| |
3659 |
| - | |
| 3659 | + | |
| 3660 | + | |
| 3661 | + | |
3660 | 3662 |
| |
3661 | 3663 |
| |
3662 | 3664 |
| |
| |||
3665 | 3667 |
| |
3666 | 3668 |
| |
3667 | 3669 |
| |
| 3670 | + | |
3668 | 3671 |
| |
3669 | 3672 |
| |
3670 | 3673 |
| |
|
Lines changed: 122 additions & 21 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
24 | 24 |
| |
25 | 25 |
| |
26 | 26 |
| |
27 |
| - | |
28 |
| - | |
29 |
| - | |
30 |
| - | |
31 |
| - | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
32 | 35 |
| |
33 | 36 |
| |
34 | 37 |
| |
| |||
177 | 180 |
| |
178 | 181 |
| |
179 | 182 |
| |
180 |
| - | |
| 183 | + | |
| 184 | + | |
181 | 185 |
| |
182 | 186 |
| |
183 |
| - | |
| 187 | + | |
184 | 188 |
| |
185 |
| - | |
186 |
| - | |
| 189 | + | |
| 190 | + | |
187 | 191 |
| |
188 | 192 |
| |
189 | 193 |
| |
| |||
213 | 217 |
| |
214 | 218 |
| |
215 | 219 |
| |
| 220 | + | |
216 | 221 |
| |
217 | 222 |
| |
218 | 223 |
| |
| |||
299 | 304 |
| |
300 | 305 |
| |
301 | 306 |
| |
302 |
| - | |
| 307 | + | |
303 | 308 |
| |
304 | 309 |
| |
305 | 310 |
| |
306 | 311 |
| |
| 312 | + | |
| 313 | + | |
| 314 | + | |
307 | 315 |
| |
308 | 316 |
| |
309 | 317 |
| |
| |||
676 | 684 |
| |
677 | 685 |
| |
678 | 686 |
| |
679 |
| - | |
| 687 | + | |
680 | 688 |
| |
681 | 689 |
| |
682 | 690 |
| |
| |||
1053 | 1061 |
| |
1054 | 1062 |
| |
1055 | 1063 |
| |
1056 |
| - | |
| 1064 | + | |
1057 | 1065 |
| |
1058 | 1066 |
| |
1059 | 1067 |
| |
| |||
1103 | 1111 |
| |
1104 | 1112 |
| |
1105 | 1113 |
| |
1106 |
| - | |
| 1114 | + | |
1107 | 1115 |
| |
1108 | 1116 |
| |
1109 | 1117 |
| |
| |||
1290 | 1298 |
| |
1291 | 1299 |
| |
1292 | 1300 |
| |
| 1301 | + | |
| 1302 | + | |
| 1303 | + | |
| 1304 | + | |
| 1305 | + | |
| 1306 | + | |
| 1307 | + | |
| 1308 | + | |
1293 | 1309 |
| |
1294 | 1310 |
| |
1295 | 1311 |
| |
| |||
1299 | 1315 |
| |
1300 | 1316 |
| |
1301 | 1317 |
| |
1302 |
| - | |
| 1318 | + | |
1303 | 1319 |
| |
1304 | 1320 |
| |
1305 | 1321 |
| |
| |||
1373 | 1389 |
| |
1374 | 1390 |
| |
1375 | 1391 |
| |
| 1392 | + | |
| 1393 | + | |
| 1394 | + | |
| 1395 | + | |
| 1396 | + | |
| 1397 | + | |
| 1398 | + | |
| 1399 | + | |
| 1400 | + | |
| 1401 | + | |
| 1402 | + | |
| 1403 | + | |
| 1404 | + | |
| 1405 | + | |
| 1406 | + | |
| 1407 | + | |
1376 | 1408 |
| |
1377 | 1409 |
| |
1378 | 1410 |
| |
| |||
2095 | 2127 |
| |
2096 | 2128 |
| |
2097 | 2129 |
| |
2098 |
| - | |
| 2130 | + | |
| 2131 | + | |
| 2132 | + | |
| 2133 | + | |
| 2134 | + | |
| 2135 | + | |
| 2136 | + | |
| 2137 | + | |
2099 | 2138 |
| |
2100 | 2139 |
| |
2101 | 2140 |
| |
2102 | 2141 |
| |
2103 | 2142 |
| |
2104 |
| - | |
| 2143 | + | |
2105 | 2144 |
| |
2106 | 2145 |
| |
2107 | 2146 |
| |
| |||
2841 | 2880 |
| |
2842 | 2881 |
| |
2843 | 2882 |
| |
2844 |
| - | |
| 2883 | + | |
| 2884 | + | |
| 2885 | + | |
| 2886 | + | |
| 2887 | + | |
| 2888 | + | |
| 2889 | + | |
| 2890 | + | |
| 2891 | + | |
| 2892 | + | |
| 2893 | + | |
| 2894 | + | |
| 2895 | + | |
| 2896 | + | |
| 2897 | + | |
| 2898 | + | |
| 2899 | + | |
2845 | 2900 |
| |
2846 | 2901 |
| |
2847 | 2902 |
| |
| |||
2856 | 2911 |
| |
2857 | 2912 |
| |
2858 | 2913 |
| |
2859 |
| - | |
| 2914 | + | |
2860 | 2915 |
| |
2861 | 2916 |
| |
2862 | 2917 |
| |
| |||
2869 | 2924 |
| |
2870 | 2925 |
| |
2871 | 2926 |
| |
2872 |
| - | |
| 2927 | + | |
| 2928 | + | |
2873 | 2929 |
| |
2874 | 2930 |
| |
2875 | 2931 |
| |
2876 | 2932 |
| |
2877 | 2933 |
| |
2878 |
| - | |
2879 |
| - | |
| 2934 | + | |
2880 | 2935 |
| |
2881 | 2936 |
| |
2882 | 2937 |
| |
| |||
2954 | 3009 |
| |
2955 | 3010 |
| |
2956 | 3011 |
| |
| 3012 | + | |
| 3013 | + | |
| 3014 | + | |
| 3015 | + | |
| 3016 | + | |
| 3017 | + | |
| 3018 | + | |
| 3019 | + | |
| 3020 | + | |
| 3021 | + | |
| 3022 | + | |
| 3023 | + | |
| 3024 | + | |
| 3025 | + | |
| 3026 | + | |
| 3027 | + | |
| 3028 | + | |
| 3029 | + | |
| 3030 | + | |
| 3031 | + | |
| 3032 | + | |
| 3033 | + | |
| 3034 | + | |
| 3035 | + | |
| 3036 | + | |
| 3037 | + | |
| 3038 | + | |
| 3039 | + | |
| 3040 | + | |
| 3041 | + | |
| 3042 | + | |
| 3043 | + | |
| 3044 | + | |
| 3045 | + | |
| 3046 | + | |
| 3047 | + | |
| 3048 | + | |
| 3049 | + | |
| 3050 | + | |
| 3051 | + | |
| 3052 | + | |
| 3053 | + | |
| 3054 | + | |
| 3055 | + | |
2957 | 3056 |
| |
2958 | 3057 |
| |
2959 | 3058 |
| |
| |||
2987 | 3086 |
| |
2988 | 3087 |
| |
2989 | 3088 |
| |
| 3089 | + | |
| 3090 | + | |
2990 | 3091 |
| |
2991 | 3092 |
| |
2992 | 3093 |
| |
|
Lines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
44 | 44 |
| |
45 | 45 |
| |
46 | 46 |
| |
| 47 | + | |
47 | 48 |
| |
48 | 49 |
| |
49 | 50 |
| |
|
Lines changed: 2 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
24 | 24 |
| |
25 | 25 |
| |
26 | 26 |
| |
27 |
| - | |
| 27 | + | |
| 28 | + | |
28 | 29 |
| |
29 | 30 |
| |
30 | 31 |
| |
|
0 commit comments
Comments
(0)