Repository navigation
fix(remote-job): stop leaked Linux workers with single-flight ownership and idle timeout - #60
Merged
Merged
Conversation
added 5 commits
October 7, 2026 16:28
…omio/firstmate PR #60 (run 37640667274), in tests/fm-remote-job.test.sh: "not ok - a worker whose state root vanished exited cleanly instead of failing for its supervisor to restart". Caused by this PR's code. Root cause (inferred from the code and the CI log; I did not reproduce the failure locally, it is timing-dependent): the new worker_ownership_intact in bin/fm-remote-job-worker.sh checked that the state root and worker.lock exist first, then read the owner record. If the state root was deleted between that check and the reads, the failed pid read returned 2 ("ownership moved to another process"), so the worker exited 0 instead of 1. A supervisor would then not restart it. Fix (bin/fm-remote-job-worker.sh only, uncommitted in the worktree): the owner-record comparison moved into worker_owner_record_matches, and worker_ownership_intact now inspects the state tree only after the record fails to match. A vanished root or lock always reports 1 (exit 1); only a mismatch with the tree still present reports 2 (displaced, exit 0). The owner identity proof, heartbeat fencing and idle timeout are otherwise unchanged. No test changes; the existing tripwire test is the regression. Verification: tests/fm-remote-job.test.sh passed 3 of 3 local runs (35 ok each, including the deleted-state-root tripwire); tests/fm-on.test.sh passed; shellcheck -x on the worker is clean. The full serial shard 2 lane was not re-run locally
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.
Summary
Fix remote Linux second-mate job workers accumulating after SSH clients disappear or ownership becomes ambiguous.
The root cause was split-brain ownership: stale heartbeat handling could start a replacement when the recorded owner could not be disproved, while an existing
--serveworker did not continuously fence itself against lock replacement and had no idle retirement path.Changes
No broad process matching or
pkill -fis used. No command was run againstwks-domio.Validation
tests/fm-remote-job.test.shtests/fm-on.test.shtests/fm-remote-job-orphan-reap.test.shstill hits its existing host-specific fixture precondition locally because this environment reparents the fixture outside PID 1; the same precondition fails on the base revision, and CI covers the repository behavior suite.Validated head:
006cb01c21428642920e8f401c297738bdc07ee3.Pipeline
Updates from git push no-mistakes