Repository navigation
[#1703] Stop child workers before pid-file removal - #1721
manishpatel00 wants to merge 1 commit into
Conversation
|
i'd offered to work on this in #1703 and was waiting for @jesperpedersen to confirm the direction, so a heads-up first would have been nice. since i traced it there, here's a review. the ordering looks right: signal, wait, then remove the pid file and destroy shared memory, on both the normal and the error path. resetting the dispositions in the child also fixes the ctrl-c reproduction from the issue, since the terminal sends SIGINT to the whole foreground group. two gaps from the issue are still open though:
smaller: the atfork handler resets all seven watched signals (main.c:2637), so SIGHUP, SIGALRM and SIGUSR1 now terminate a child instead of being swallowed. as far as i can see nothing sends those to children today, so it's probably fine, but limiting it to SIGTERM/SIGINT (plus SIGCHLD) keeps the change to what the issue needs. the red static-analysis and clang debug jobs fail the same way on main right now, so they're not from this. |
|
@manishpatel00 remember to squash |
|
remove the pid file before kill(0, SIGTERM) on the error path, or stop the parent signalling itself |
752e355 to
a5387d8
Compare
|
@manishpatel00 rebase onto pgmoneta/pgmoneta#1723 and drop the art.c 17 → 18 baseline change. |
a5387d8 to
39e1f7a
Compare
|
@manishpatel00 remember to squash |
39e1f7a to
b9320cb
Compare
|
Done — rebased onto the latest upstream/main and squashed into exactly one signed commit. The unrelated art.c cppcheck baseline change was removed. Revalidated clang-format, cppcheck, git diff --check, and the pgmoneta-bin/pgmoneta-test builds. |
|
@manishpatel00 LGTM now |
Forked workers inherit the server signal dispositions but do not run the parent libev loop, so shutdown signals can leave direct workers alive. Track every server child, restore the required signal defaults after fork, and shut children down directly in every run mode with bounded waiting and SIGKILL escalation. Remove the pid file before the error-path process-group signal so kill(0, SIGTERM) cannot leave stale parent identity during cleanup. Keep shared-memory cleanup after child shutdown. Fixes pgmoneta#1703 Signed-off-by: Manish Kumar <[email protected]>
b9320cb to
99186d1
Compare
|
@manishpatel00 fix the pr title |
Fixes #1703
Forked workers inherit the server's libev signal handlers without running the parent event loop, so targeted SIGTERM can leave foreground workers alive. The server now resets SIGTERM, SIGINT, and SIGCHLD dispositions in forked children and records worker PIDs at server fork sites. Shutdown signals tracked children directly in every run mode, waits up to five seconds, then sends SIGKILL and allows a further bounded reap interval; any remaining PIDs are logged before cleanup proceeds.
The pid file and shared memory are cleaned up only after the bounded child wait. The existing process-group signal remains limited to daemon/management-stop shutdowns.
Validation:
cmake --build /tmp/pgmoneta-1703-build --target pgmoneta-bin pgmoneta-test --parallel 4passed. The fullpgmoneta-testrunner stalled after AES fault-test output; container tests could not run because the Docker daemon was unavailable.