forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit28724fd
committed
Report failure to start a background worker.
When a worker is flagged as BGW_NEVER_RESTART and we fail to start it,or if it is not marked BGW_NEVER_RESTART but is terminated beforestartup succeeds, what BgwHandleStatus should be reported? Theprevious code really hadn't considered this possibility (as indicatedby the comments which ignore it completely) and would typically returnBGWH_NOT_YET_STARTED, but that's not a good answer, because thenthere's no way for code using GetBackgroundWorkerPid() to tell thedifference between a worker that has not started but will startlater and a worker that has not started and will never be started.So, when this case happens, return BGWH_STOPPED instead. Update thecomments to reflect this.The preceding fix by itself is insufficient to fix the problem,because the old code also didn't send a notification to the processidentified in bgw_notify_pid when startup failed. That might'vebeen technically correct under the theory that the status of theworker was BGWH_NOT_YET_STARTED, because the status would indeed notchange when the worker failed to start, but now that we're moreusefully reporting BGWH_STOPPED, a notification is needed.Without these fixes, code which starts background workers and thenuses the recommended APIs to wait for those background workers tostart would hang indefinitely if the postmaster failed to fork aworker.Amit Kapila and Robert HaasDiscussion:http://postgr.es/m/CAA4eK1KDfKkvrjxsKJi3WPyceVi3dH1VCkbTJji2fuwKuB=3uw@mail.gmail.com1 parent9c64ddd commit28724fd
2 files changed
+24
-8
lines changedLines changed: 15 additions & 8 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1034 | 1034 |
| |
1035 | 1035 |
| |
1036 | 1036 |
| |
1037 |
| - | |
1038 |
| - | |
1039 |
| - | |
1040 |
| - | |
| 1037 | + | |
| 1038 | + | |
| 1039 | + | |
1041 | 1040 |
| |
1042 |
| - | |
1043 |
| - | |
1044 |
| - | |
| 1041 | + | |
| 1042 | + | |
| 1043 | + | |
| 1044 | + | |
| 1045 | + | |
| 1046 | + | |
| 1047 | + | |
| 1048 | + | |
1045 | 1049 |
| |
1046 | 1050 |
| |
1047 | 1051 |
| |
| |||
1066 | 1070 |
| |
1067 | 1071 |
| |
1068 | 1072 |
| |
| 1073 | + | |
| 1074 | + | |
| 1075 | + | |
1069 | 1076 |
| |
1070 |
| - | |
| 1077 | + | |
1071 | 1078 |
| |
1072 | 1079 |
| |
1073 | 1080 |
| |
|
Lines changed: 9 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
5909 | 5909 |
| |
5910 | 5910 |
| |
5911 | 5911 |
| |
| 5912 | + | |
| 5913 | + | |
| 5914 | + | |
| 5915 | + | |
5912 | 5916 |
| |
| 5917 | + | |
| 5918 | + | |
| 5919 | + | |
| 5920 | + | |
| 5921 | + | |
5913 | 5922 |
| |
5914 | 5923 |
| |
5915 | 5924 |
| |
|
0 commit comments
Comments
(0)