Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit28a520c

Browse files
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.fi
1 parentb43100f commit28a520c

File tree

3 files changed

+170
-280
lines changed

3 files changed

+170
-280
lines changed

‎src/backend/postmaster/bgworker.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -401,9 +401,7 @@ BackgroundWorkerStateChange(bool allow_new_workers)
401401
}
402402

403403
/* Initialize postmaster bookkeeping. */
404-
rw->rw_backend=NULL;
405404
rw->rw_pid=0;
406-
rw->rw_child_slot=0;
407405
rw->rw_crashed_at=0;
408406
rw->rw_shmem_slot=slotno;
409407
rw->rw_terminate= false;
@@ -1026,9 +1024,7 @@ RegisterBackgroundWorker(BackgroundWorker *worker)
10261024
}
10271025

10281026
rw->rw_worker=*worker;
1029-
rw->rw_backend=NULL;
10301027
rw->rw_pid=0;
1031-
rw->rw_child_slot=0;
10321028
rw->rw_crashed_at=0;
10331029
rw->rw_terminate= false;
10341030

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp