forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit0fae846
committed
Fix some minor postmaster-state-machine issues.
In sigusr1_handler, don't ignore PMSIGNAL_ADVANCE_STATE_MACHINE basedon pmState. The restriction is unnecessary (PostmasterStateMachineshould work in any state), not future-proof (since it makes too manyassumptions about why the signal might be sent), and broken even todaybecause a race condition can make it necessary to respond to the signalin PM_WAIT_READONLY state. The race condition seems unlikely, butif it did happen, a hot-standby postmaster could fail to shut downafter receiving a smart-shutdown request.In MaybeStartWalReceiver, don't clear the WalReceiverRequested flagif the fork attempt fails. Leaving it set allows us to tryagain in future iterations of the postmaster idle loop. (The startupprocess would eventually send a fresh request signal, but this changemay allow us to retry the fork sooner.)Remove an obsolete comment and unnecessary test inPostmasterStateMachine's handling of PM_SHUTDOWN_2 state. It's notpossible to have a live walreceiver in that state, and AFAICT has notbeen possible since commit5e85315. This isn't a live bug, but thefalse comment is quite confusing to readers.In passing, rearrange sigusr1_handler's CheckPromoteSignal tests so thatwe don't uselessly perform stat() calls that we're going to ignore theresults of.Add some comments clarifying the behavior of MaybeStartWalReceiver;I very nearly rearranged it in a way that'd reintroduce the racecondition fixed ine5d494d. Mea culpa for not commenting thatproperly at the time.Back-patch to all supported branches. The PMSIGNAL_ADVANCE_STATE_MACHINEchange is the only one of even minor significance, but we might as wellkeep this code in sync across branches.Discussion:https://postgr.es/m/9001.1556046681@sss.pgh.pa.us1 parent0a999e1 commit0fae846
1 file changed
+26
-11
lines changedLines changed: 26 additions & 11 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3811 | 3811 |
| |
3812 | 3812 |
| |
3813 | 3813 |
| |
3814 |
| - | |
3815 |
| - | |
3816 |
| - | |
3817 | 3814 |
| |
3818 |
| - | |
3819 |
| - | |
| 3815 | + | |
3820 | 3816 |
| |
3821 | 3817 |
| |
3822 | 3818 |
| |
| |||
5213 | 5209 |
| |
5214 | 5210 |
| |
5215 | 5211 |
| |
5216 |
| - | |
5217 |
| - | |
| 5212 | + | |
| 5213 | + | |
| 5214 | + | |
| 5215 | + | |
| 5216 | + | |
| 5217 | + | |
| 5218 | + | |
| 5219 | + | |
| 5220 | + | |
| 5221 | + | |
| 5222 | + | |
5218 | 5223 |
| |
5219 |
| - | |
5220 | 5224 |
| |
5221 | 5225 |
| |
5222 | 5226 |
| |
5223 |
| - | |
| 5227 | + | |
5224 | 5228 |
| |
5225 |
| - | |
| 5229 | + | |
| 5230 | + | |
5226 | 5231 |
| |
5227 | 5232 |
| |
5228 | 5233 |
| |
| |||
5518 | 5523 |
| |
5519 | 5524 |
| |
5520 | 5525 |
| |
| 5526 | + | |
| 5527 | + | |
| 5528 | + | |
| 5529 | + | |
| 5530 | + | |
| 5531 | + | |
| 5532 | + | |
| 5533 | + | |
5521 | 5534 |
| |
5522 | 5535 |
| |
5523 | 5536 |
| |
| |||
5528 | 5541 |
| |
5529 | 5542 |
| |
5530 | 5543 |
| |
5531 |
| - | |
| 5544 | + | |
| 5545 | + | |
| 5546 | + | |
5532 | 5547 |
| |
5533 | 5548 |
| |
5534 | 5549 |
| |
|
0 commit comments
Comments
(0)