forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commita4d1ce0
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 parentf6af9c7 commita4d1ce0
1 file changed
+32
-7
lines changedLines changed: 32 additions & 7 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
354 | 354 |
| |
355 | 355 |
| |
356 | 356 |
| |
| 357 | + | |
| 358 | + | |
| 359 | + | |
357 | 360 |
| |
358 | 361 |
| |
359 | 362 |
| |
| |||
417 | 420 |
| |
418 | 421 |
| |
419 | 422 |
| |
| 423 | + | |
420 | 424 |
| |
421 | 425 |
| |
422 | 426 |
| |
| |||
1783 | 1787 |
| |
1784 | 1788 |
| |
1785 | 1789 |
| |
| 1790 | + | |
| 1791 | + | |
| 1792 | + | |
| 1793 | + | |
1786 | 1794 |
| |
1787 | 1795 |
| |
1788 | 1796 |
| |
| |||
2923 | 2931 |
| |
2924 | 2932 |
| |
2925 | 2933 |
| |
2926 |
| - | |
| 2934 | + | |
| 2935 | + | |
2927 | 2936 |
| |
2928 | 2937 |
| |
2929 | 2938 |
| |
| |||
5011 | 5020 |
| |
5012 | 5021 |
| |
5013 | 5022 |
| |
5014 |
| - | |
5015 |
| - | |
5016 |
| - | |
5017 |
| - | |
5018 |
| - | |
| 5023 | + | |
5019 | 5024 |
| |
5020 | 5025 |
| |
5021 |
| - | |
| 5026 | + | |
| 5027 | + | |
| 5028 | + | |
5022 | 5029 |
| |
5023 | 5030 |
| |
5024 | 5031 |
| |
| |||
5369 | 5376 |
| |
5370 | 5377 |
| |
5371 | 5378 |
| |
| 5379 | + | |
| 5380 | + | |
| 5381 | + | |
| 5382 | + | |
| 5383 | + | |
| 5384 | + | |
| 5385 | + | |
| 5386 | + | |
| 5387 | + | |
| 5388 | + | |
| 5389 | + | |
| 5390 | + | |
| 5391 | + | |
| 5392 | + | |
| 5393 | + | |
| 5394 | + | |
| 5395 | + | |
| 5396 | + | |
5372 | 5397 |
| |
5373 | 5398 |
| |
5374 | 5399 |
| |
|
0 commit comments
Comments
(0)