forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitc6c3334
committed
Prevent possibility of panics during shutdown checkpoint.
When the checkpointer writes the shutdown checkpoint, it checksafterwards whether any WAL has been written since it started andthrows a PANIC if so. At that point, only walsenders are stillactive, so one might think this could not happen, but walsenders canalso generate WAL, for instance in BASE_BACKUP and logical decodingrelated commands (e.g. via hint bits). So they can trigger this panicif such a command is run while the shutdown checkpoint is beingwritten.To fix this, divide the walsender shutdown into two phases. First,checkpointer, itself triggered by postmaster, sends aPROCSIG_WALSND_INIT_STOPPING signal to all walsenders. If the backendis idle or runs an SQL query this causes the backend to shutdown, iflogical replication is in progress all existing WAL records areprocessed followed by a shutdown. Otherwise this causes the walsenderto switch to the "stopping" state. In this state, the walsender willreject any further replication commands. The checkpointer begins theshutdown checkpoint once all walsenders are confirmed asstopping. When the shutdown checkpoint finishes, the postmaster sendsus SIGUSR2. This instructs walsender to send any outstanding WAL,including the shutdown checkpoint record, wait for it to be replicatedto the standby, and then exit.Author: Andres Freund, based on an earlier patch by Michael PaquierReported-By: Fujii Masao, Andres FreundReviewed-By: Michael PaquierDiscussion:https://postgr.es/m/20170602002912.tqlwn4gymzlxpvs2@alap3.anarazel.deBackpatch: 9.4, where logical decoding was introduced1 parent47fd420 commitc6c3334
File tree
7 files changed
+186
-28
lines changed- doc/src/sgml
- src
- backend
- access/transam
- replication
- storage/ipc
- include
- replication
- storage
7 files changed
+186
-28
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: 11 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
8324 | 8324 |
| |
8325 | 8325 |
| |
8326 | 8326 |
| |
| 8327 | + | |
| 8328 | + | |
| 8329 | + | |
| 8330 | + | |
| 8331 | + | |
| 8332 | + | |
| 8333 | + | |
| 8334 | + | |
| 8335 | + | |
| 8336 | + | |
| 8337 | + | |
8327 | 8338 |
| |
8328 | 8339 |
| |
8329 | 8340 |
| |
|
Lines changed: 160 additions & 27 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 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
32 | 38 |
| |
33 | 39 |
| |
34 | 40 |
| |
| |||
177 | 183 |
| |
178 | 184 |
| |
179 | 185 |
| |
180 |
| - | |
| 186 | + | |
| 187 | + | |
181 | 188 |
| |
182 | 189 |
| |
183 |
| - | |
184 |
| - | |
185 |
| - | |
186 |
| - | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
187 | 194 |
| |
188 | 195 |
| |
189 | 196 |
| |
| |||
300 | 307 |
| |
301 | 308 |
| |
302 | 309 |
| |
303 |
| - | |
| 310 | + | |
| 311 | + | |
304 | 312 |
| |
305 | 313 |
| |
306 | 314 |
| |
| |||
677 | 685 |
| |
678 | 686 |
| |
679 | 687 |
| |
680 |
| - | |
| 688 | + | |
681 | 689 |
| |
682 | 690 |
| |
683 | 691 |
| |
| |||
1055 | 1063 |
| |
1056 | 1064 |
| |
1057 | 1065 |
| |
1058 |
| - | |
| 1066 | + | |
1059 | 1067 |
| |
1060 | 1068 |
| |
1061 | 1069 |
| |
| |||
1106 | 1114 |
| |
1107 | 1115 |
| |
1108 | 1116 |
| |
1109 |
| - | |
| 1117 | + | |
1110 | 1118 |
| |
1111 | 1119 |
| |
1112 | 1120 |
| |
| |||
1311 | 1319 |
| |
1312 | 1320 |
| |
1313 | 1321 |
| |
| 1322 | + | |
| 1323 | + | |
| 1324 | + | |
| 1325 | + | |
| 1326 | + | |
| 1327 | + | |
| 1328 | + | |
| 1329 | + | |
1314 | 1330 |
| |
1315 | 1331 |
| |
1316 | 1332 |
| |
| |||
1326 | 1342 |
| |
1327 | 1343 |
| |
1328 | 1344 |
| |
1329 |
| - | |
| 1345 | + | |
1330 | 1346 |
| |
1331 | 1347 |
| |
1332 | 1348 |
| |
| |||
1400 | 1416 |
| |
1401 | 1417 |
| |
1402 | 1418 |
| |
| 1419 | + | |
| 1420 | + | |
| 1421 | + | |
| 1422 | + | |
| 1423 | + | |
| 1424 | + | |
| 1425 | + | |
| 1426 | + | |
| 1427 | + | |
| 1428 | + | |
| 1429 | + | |
| 1430 | + | |
| 1431 | + | |
| 1432 | + | |
| 1433 | + | |
| 1434 | + | |
1403 | 1435 |
| |
1404 | 1436 |
| |
1405 | 1437 |
| |
| |||
2128 | 2160 |
| |
2129 | 2161 |
| |
2130 | 2162 |
| |
2131 |
| - | |
| 2163 | + | |
2132 | 2164 |
| |
2133 | 2165 |
| |
2134 | 2166 |
| |
| |||
2443 | 2475 |
| |
2444 | 2476 |
| |
2445 | 2477 |
| |
| 2478 | + | |
| 2479 | + | |
| 2480 | + | |
| 2481 | + | |
2446 | 2482 |
| |
2447 | 2483 |
| |
2448 | 2484 |
| |
| |||
2733 | 2769 |
| |
2734 | 2770 |
| |
2735 | 2771 |
| |
| 2772 | + | |
2736 | 2773 |
| |
| 2774 | + | |
| 2775 | + | |
| 2776 | + | |
| 2777 | + | |
| 2778 | + | |
| 2779 | + | |
| 2780 | + | |
| 2781 | + | |
2737 | 2782 |
| |
2738 | 2783 |
| |
2739 | 2784 |
| |
| |||
2843 | 2888 |
| |
2844 | 2889 |
| |
2845 | 2890 |
| |
| 2891 | + | |
| 2892 | + | |
| 2893 | + | |
| 2894 | + | |
| 2895 | + | |
| 2896 | + | |
| 2897 | + | |
| 2898 | + | |
| 2899 | + | |
| 2900 | + | |
| 2901 | + | |
| 2902 | + | |
| 2903 | + | |
| 2904 | + | |
| 2905 | + | |
| 2906 | + | |
| 2907 | + | |
| 2908 | + | |
| 2909 | + | |
| 2910 | + | |
2846 | 2911 |
| |
2847 | 2912 |
| |
2848 | 2913 |
| |
| |||
2856 | 2921 |
| |
2857 | 2922 |
| |
2858 | 2923 |
| |
2859 |
| - | |
| 2924 | + | |
| 2925 | + | |
| 2926 | + | |
| 2927 | + | |
| 2928 | + | |
2860 | 2929 |
| |
2861 | 2930 |
| |
2862 | 2931 |
| |
2863 | 2932 |
| |
2864 | 2933 |
| |
2865 |
| - | |
2866 |
| - | |
2867 |
| - | |
2868 |
| - | |
2869 |
| - | |
2870 |
| - | |
2871 |
| - | |
2872 |
| - | |
2873 |
| - | |
2874 |
| - | |
| 2934 | + | |
2875 | 2935 |
| |
2876 | 2936 |
| |
2877 | 2937 |
| |
| |||
2969 | 3029 |
| |
2970 | 3030 |
| |
2971 | 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 | + | |
| 3056 | + | |
| 3057 | + | |
| 3058 | + | |
| 3059 | + | |
| 3060 | + | |
| 3061 | + | |
| 3062 | + | |
| 3063 | + | |
| 3064 | + | |
| 3065 | + | |
| 3066 | + | |
| 3067 | + | |
| 3068 | + | |
| 3069 | + | |
| 3070 | + | |
| 3071 | + | |
| 3072 | + | |
| 3073 | + | |
| 3074 | + | |
| 3075 | + | |
| 3076 | + | |
| 3077 | + | |
| 3078 | + | |
| 3079 | + | |
| 3080 | + | |
| 3081 | + | |
| 3082 | + | |
| 3083 | + | |
| 3084 | + | |
| 3085 | + | |
| 3086 | + | |
| 3087 | + | |
| 3088 | + | |
| 3089 | + | |
| 3090 | + | |
| 3091 | + | |
| 3092 | + | |
| 3093 | + | |
| 3094 | + | |
| 3095 | + | |
| 3096 | + | |
| 3097 | + | |
| 3098 | + | |
| 3099 | + | |
| 3100 | + | |
| 3101 | + | |
| 3102 | + | |
2972 | 3103 |
| |
2973 | 3104 |
| |
2974 | 3105 |
| |
| |||
3002 | 3133 |
| |
3003 | 3134 |
| |
3004 | 3135 |
| |
| 3136 | + | |
| 3137 | + | |
3005 | 3138 |
| |
3006 | 3139 |
| |
3007 | 3140 |
| |
|
Lines changed: 4 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
20 | 20 |
| |
21 | 21 |
| |
22 | 22 |
| |
| 23 | + | |
23 | 24 |
| |
24 | 25 |
| |
25 | 26 |
| |
| |||
270 | 271 |
| |
271 | 272 |
| |
272 | 273 |
| |
| 274 | + | |
| 275 | + | |
| 276 | + | |
273 | 277 |
| |
274 | 278 |
| |
275 | 279 |
| |
|
Lines changed: 3 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
44 | 44 |
| |
45 | 45 |
| |
46 | 46 |
| |
| 47 | + | |
| 48 | + | |
| 49 | + | |
47 | 50 |
| |
48 | 51 |
| |
49 | 52 |
| |
|
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 |
| |
|
Lines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
32 | 32 |
| |
33 | 33 |
| |
34 | 34 |
| |
| 35 | + | |
35 | 36 |
| |
36 | 37 |
| |
37 | 38 |
| |
|
0 commit comments
Comments
(0)