- Notifications
You must be signed in to change notification settings - Fork28
Commite5d494d
committed
Don't lose walreceiver start requests due to race condition in postmaster.
When a walreceiver dies, the startup process will notice that and senda PMSIGNAL_START_WALRECEIVER signal to the postmaster, asking for a newwalreceiver to be launched. There's a race condition, which at leastin HEAD is very easy to hit, whereby the postmaster might see thatsignal before it processes the SIGCHLD from the walreceiver process.In that situation, sigusr1_handler() just dropped the start requeston the floor, reasoning that it must be redundant. Eventually, after10 seconds (WALRCV_STARTUP_TIMEOUT), the startup process would make afresh request --- but that's a long time if the connection could havebeen re-established almost immediately.Fix it by setting a state flag inside the postmaster that we won'tclear until we do launch a walreceiver. In cases where that resultsin an extra walreceiver launch, it's up to the walreceiver to realizeit's unwanted and go away --- but we have, and need, that logic anywayfor the opposite race case.I came across this through investigating unexpected delays in thesrc/test/recovery TAP tests: it manifests there in test cases wherea master server is stopped and restarted while leaving streamingslaves active.This logic has been broken all along, so back-patch to all supportedbranches.Discussion:https://postgr.es/m/21344.1498494720@sss.pgh.pa.us1 parentad1b5c8 commite5d494d
1 file changed
+32
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
357 | 357 | | |
358 | 358 | | |
359 | 359 | | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
360 | 363 | | |
361 | 364 | | |
362 | 365 | | |
| |||
426 | 429 | | |
427 | 430 | | |
428 | 431 | | |
| 432 | + | |
429 | 433 | | |
430 | 434 | | |
431 | 435 | | |
| |||
1810 | 1814 | | |
1811 | 1815 | | |
1812 | 1816 | | |
| 1817 | + | |
| 1818 | + | |
| 1819 | + | |
| 1820 | + | |
1813 | 1821 | | |
1814 | 1822 | | |
1815 | 1823 | | |
| |||
2958 | 2966 | | |
2959 | 2967 | | |
2960 | 2968 | | |
2961 | | - | |
| 2969 | + | |
| 2970 | + | |
2962 | 2971 | | |
2963 | 2972 | | |
2964 | 2973 | | |
| |||
5066 | 5075 | | |
5067 | 5076 | | |
5068 | 5077 | | |
5069 | | - | |
5070 | | - | |
5071 | | - | |
5072 | | - | |
5073 | | - | |
| 5078 | + | |
5074 | 5079 | | |
5075 | 5080 | | |
5076 | | - | |
| 5081 | + | |
| 5082 | + | |
| 5083 | + | |
5077 | 5084 | | |
5078 | 5085 | | |
5079 | 5086 | | |
| |||
5409 | 5416 | | |
5410 | 5417 | | |
5411 | 5418 | | |
| 5419 | + | |
| 5420 | + | |
| 5421 | + | |
| 5422 | + | |
| 5423 | + | |
| 5424 | + | |
| 5425 | + | |
| 5426 | + | |
| 5427 | + | |
| 5428 | + | |
| 5429 | + | |
| 5430 | + | |
| 5431 | + | |
| 5432 | + | |
| 5433 | + | |
| 5434 | + | |
| 5435 | + | |
| 5436 | + | |
5412 | 5437 | | |
5413 | 5438 | | |
5414 | 5439 | | |
| |||
0 commit comments
Comments
(0)