fix(kanban): detect darwin zombie workers (salvages #20023)#20188
Merged
Conversation
1 task
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.
Kanban dispatcher now correctly detects zombie worker processes on macOS, so crashed workers get reclaimed on the next tick instead of tying up their task for the full
claim_expireswindow (~15 min).Salvaged from #20023 (@LeonSGP43).
Root cause:
_pid_alive()usedos.kill(pid, 0)which succeeds for zombie processes because the process table entry still exists post-exit, pre-reap. On Linux it fell through to/proc/<pid>/statusto readState: Z, but on macOS there's no/proc, so the zombie check was a documented no-op. A worker that crashed at startup (missing skill, bad credential, import error) stayed "alive" to the dispatcher until claim TTL expired, creating a ~5 min dispatcher cadence × 15 min TTL = 3+ wasted re-spawn attempts per stuck task, all of which crashed identically.Changes
hermes_cli/kanban_db.py: afterkill(pid, 0)succeeds on Darwin, shell out tops -o stat= -p <pid>with a 1s timeout. Return False ifpsexits non-zero (no such process) or if the BSD stat field containsZ. If the probe itself errors, keep the optimistickill(0)answer — conservative default.tests/hermes_cli/test_kanban_core_functionality.py: newtest_pid_alive_detects_darwin_zombiecovering the Darwin branch with a mockedpsreturningZ+./proc/<pid>/statuspath unchanged.Validation
_pid_alive→ True for ~15 min until claim_expires; dispatcher re-spawns 3+ times_pid_alive→ False on next tick; task reclaimed via crashed-worker path/proc/<pid>/statuspeek returns False (unchanged)psprobe fails (unexpected)kill(0)answer (optimistic)test_kanban_core_functionality+test_kanban_db)Closes #20015
Co-authored-by: LeonSGP43 cine.dreamer.one@gmail.com