fix(node_info): reap zombie pve_mod_worker and orphaned collector processes - #307
Merged
Conversation
Meliox
marked this pull request as draft
August 18, 2026 18:44
Meliox
force-pushed
the
reap-zombie-worker-processes
branch
from
August 22, 2026 16:29
30cb087 to
acf4711
Compare
Meliox
marked this pull request as ready for review
August 22, 2026 18:08
added 2 commits
August 22, 2026 23:41
…cesses Double-forks pve_mod_worker so it is reparented to init instead of the calling process, which reaps it immediately on exit and prevents it lingering as a <defunct> zombie. Also adds startup-time reaping of orphaned collector-* processes (ppid==1) left behind if a worker was previously killed with SIGKILL, and an opportunistic waitpid(WNOHANG) in _worker_lock_file_exists as a cheap supplemental reap.
Meliox
force-pushed
the
reap-zombie-worker-processes
branch
from
August 22, 2026 21:45
86fefc5 to
103181d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Follow-up to #306. and an attempt to resolve side note in #305. Two related issues remained:
pve_mod_workerprocesses stay behind as<defunct>zombies._pve_mod_worker()did a singlefork(), so the worker's parent was whatever process calledpve_mod_starter()(e.g. a pveproxy pool worker). That process never reaps the PID, and since pveproxy dispatches requests across a pool, the process that later notices the worker is gone is often not its actual parent — so the zombie can only be cleaned up incidentally, if ever.SIGKILL(uncatchable) or crashes,$SIG{TERM}/$SIG{INT}and theENDblock never run, so_stop_child_collectors()is skipped. Its collector children (e.g.collector-temperature-sensors) get reparented to init and keep running orphaned indefinitely.Fix
_pve_mod_worker(): an intermediate process forks the real worker and exits immediately, reparenting the worker to init (PID 1). Init always reaps its children, so the worker can never outlive its own exit as a zombie, regardless of which process later callspve_mod_starter(). The original callerwaitpid()s the short-lived intermediate process so that one doesn't zombie either._reap_orphaned_collectors(): runs at the top of_pve_mod_keep_alive()on every new worker startup. Scans/procforcollector-*processes whose parent is init (ppid == 1), and terminates them (SIGTERM, then SIGKILL after a short grace period) — cleaning up stragglers left by a non-gracefully-killed previous worker._worker_lock_file_exists(): opportunistically callswaitpid($worker_pid, WNOHANG)before removing a stale/zombie lock, as a cheap supplemental reap for cases where the caller does happen to be the actual parent.get_process_ppid()helper inUtils.pm(parses/proc/<pid>/stat, same care around thecommfield as the existing zombie-detection regex).