forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit28a520c
committed
Refactor code to handle death of a backend or bgworker in postmaster
Currently, when a child process exits, the postmaster first scansthrough BackgroundWorkerList, to see if it the child process was abackground worker. If not found, then it scans through BackendList tosee if it was a regular backend. That leads to some duplicationbetween the bgworker and regular backend cleanup code, as both have anentry in the BackendList that needs to be cleaned up in the same way.Refactor that so that we scan just the BackendList to find the childprocess, and if it was a background worker, do the additionalbgworker-specific cleanup in addition to the normal Backend cleanup.Change HandleChildCrash so that it doesn't try to handle the cleanupof the process that already exited, only the signaling of all theother processes. When called for any of the aux processes, the callerhad already cleared the *PID global variable, so the code inHandleChildCrash() to do that was unused.On Windows, if a child process exits with ERROR_WAIT_NO_CHILDREN, it'snow logged with that exit code, instead of 0. Also, if a bgworkerexits with ERROR_WAIT_NO_CHILDREN, it's now treated as crashed and isrestarted. Previously it was treated as a normal exit.If a child process is not found in the BackendList, the log messagenow calls it "untracked child process" rather than "server process".Arguably that should be a PANIC, because we do track all the childprocesses in the list, so failing to find a child process is highlyunexpected. But if we want to change that, let's discuss and do thatas a separate commit.Reviewed-by: Thomas Munro <thomas.munro@gmail.com>Discussion:https://www.postgresql.org/message-id/835232c0-a5f7-4f20-b95b-5b56ba57d741@iki.fi1 parentb43100f commit28a520c
File tree
3 files changed
+170
-280
lines changed- src
- backend/postmaster
- include/postmaster
3 files changed
+170
-280
lines changedLines changed: 0 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
401 | 401 |
| |
402 | 402 |
| |
403 | 403 |
| |
404 |
| - | |
405 | 404 |
| |
406 |
| - | |
407 | 405 |
| |
408 | 406 |
| |
409 | 407 |
| |
| |||
1026 | 1024 |
| |
1027 | 1025 |
| |
1028 | 1026 |
| |
1029 |
| - | |
1030 | 1027 |
| |
1031 |
| - | |
1032 | 1028 |
| |
1033 | 1029 |
| |
1034 | 1030 |
| |
|
0 commit comments
Comments
(0)