forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitcb59949
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 parent456bf26 commitcb59949
1 file changed
+32
-7
lines changedLines changed: 32 additions & 7 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
370 | 370 |
| |
371 | 371 |
| |
372 | 372 |
| |
| 373 | + | |
| 374 | + | |
| 375 | + | |
373 | 376 |
| |
374 | 377 |
| |
375 | 378 |
| |
| |||
443 | 446 |
| |
444 | 447 |
| |
445 | 448 |
| |
| 449 | + | |
446 | 450 |
| |
447 | 451 |
| |
448 | 452 |
| |
| |||
1766 | 1770 |
| |
1767 | 1771 |
| |
1768 | 1772 |
| |
| 1773 | + | |
| 1774 | + | |
| 1775 | + | |
| 1776 | + | |
1769 | 1777 |
| |
1770 | 1778 |
| |
1771 | 1779 |
| |
| |||
2848 | 2856 |
| |
2849 | 2857 |
| |
2850 | 2858 |
| |
2851 |
| - | |
| 2859 | + | |
| 2860 | + | |
2852 | 2861 |
| |
2853 | 2862 |
| |
2854 | 2863 |
| |
| |||
4896 | 4905 |
| |
4897 | 4906 |
| |
4898 | 4907 |
| |
4899 |
| - | |
4900 |
| - | |
4901 |
| - | |
4902 |
| - | |
4903 |
| - | |
| 4908 | + | |
4904 | 4909 |
| |
4905 | 4910 |
| |
4906 |
| - | |
| 4911 | + | |
| 4912 | + | |
| 4913 | + | |
4907 | 4914 |
| |
4908 | 4915 |
| |
4909 | 4916 |
| |
| |||
5279 | 5286 |
| |
5280 | 5287 |
| |
5281 | 5288 |
| |
| 5289 | + | |
| 5290 | + | |
| 5291 | + | |
| 5292 | + | |
| 5293 | + | |
| 5294 | + | |
| 5295 | + | |
| 5296 | + | |
| 5297 | + | |
| 5298 | + | |
| 5299 | + | |
| 5300 | + | |
| 5301 | + | |
| 5302 | + | |
| 5303 | + | |
| 5304 | + | |
| 5305 | + | |
| 5306 | + | |
5282 | 5307 |
| |
5283 | 5308 |
| |
5284 | 5309 |
| |
|
0 commit comments
Comments
(0)