Repository navigation
Keep second mates running when a restart races the liveness check - #42
Merged
Merged
Conversation
A restart left a mate's endpoint briefly agentless between the old agent's exit and the replacement's start; the watcher's liveness tick read that as a dead mate, killed the endpoint under the restart, then collided with the restart's spawn lock and gave up, leaving the mate with no agent. - fm-control relaunch of a secondmate holds the mate's liveness lock for the whole transaction, so liveness recovery skips it; the remote restart holds this home's lock across the host-local relaunch. - fm-secondmate-restart recovers a mate whose restart failed with no agent, through the liveness library's guarded launch on the recorded profile, and reports it as failed with the mate's running state; unreached now means no running agent was confirmed. - The reported reason is the relaunch's first error line, never a warning printed on the way such as a skipped pre-launch home sync.
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.
What broke
On 27 Nov the second mate restart left a mate with no agent twice: dpz under the supervisor clear policy (#40) at 16:30Z, and ui under the ordinary update restart at 17:01Z.
Cause: between the old agent's exit and the replacement's start, a mate's endpoint reads exactly like a dead mate.
The watcher's secondmate liveness tick probed it in that window, got
dead, killed the endpoint (fm_backend_kill) under the restart, and then its own respawn was refused by the restart's spawn lock (another spawn is already creating task dpz).The restart then could not confirm its replacement (its endpoint was gone; for ui,
pane wW5:p2 not found) and reported an unknown outcome, so neither side relaunched the mate.The restart never took the per-mate liveness lock that already serializes the watcher tick, the session-start sweep, alert wakes, and teardown.
The
sync skipped before launchwarning was not a cause: fm-spawn carries on past it, butfm-secondmate-restart.shreported the first line of the relaunch output as the reason, and that line was the warning.Fix
bin/fm-control.shrelaunch of a secondmate holdsstate/.secondmate-liveness-<id>.lockfrom before anything is touched to the end of the transaction, so liveness recovery skips the mate instead of killing it mid-launch. If another recovery still holds it afterFM_CONTROL_LIVENESS_WAIT(180s), the relaunch refuses with nothing changed.bin/fm-secondmate-restart.shholds this home's liveness lock across a remote mate's host-local relaunch, since the host's transaction holds only the host's lock.fm-secondmate-restart.shprobes the mate under its liveness lock. A live mate is reported asfailed: <id>: ... the mate is still running. A dead or missing one gets the liveness library's guarded recovery launch, pinned to the recorded harness, model, and effort under--keep-profile, and is reportedfailed: ... a fresh agent was started in its place and is runningonce a probe reads it alive withinFM_SECONDMATE_RECOVER_WAIT(90s).unreachednow means no running agent could be confirmed. The summary gains afailedcount, and exit 3 covers it.error:line, never awarning:line.fm_secondmate_liveness_relaunchtakes optional extra spawn args (used for the profile pin).fm-supervisor-clear.shlogs afailed:line asrestart-failed. The/updatefirstmateskill lists the new outcome.Tests
New, in
tests/fm-secondmate-restart.test.sh:failedwith the real error, and the warning is never the reason.fm-control.shchange this test fails (raced).Changed: T5 (a pre-stop refusal is now
failed ... still running) and T11 (a stopped mate gets a recovery launch, and is stillunreachedwhen that does not come up either). The tmux stand-in now modelskill-windowandnew-window.tests/fm-supervisor-clear.test.shadds a case for afailed:outcome being logged as a failure, not a restart.Run:
tests/fm-secondmate-restart.test.sh,tests/fm-supervisor-clear.test.sh,tests/fm-secondmate-liveness.test.sh,tests/fm-alert-wake.test.sh,tests/fm-control-relaunch.test.sh: all pass.bin/fm-doc-audience-check.sh: ok.bin/fm-lint.shreports nothing in the changed files. It exits 1 only on three existing findings intests/fm-daemon.test.sh, which this branch does not touch;bin/fm-lint.sh tests/fm-daemon.test.shreports the same three on its own.All reproduction used stand-ins. No live second mate or main was touched, and there was no Herdr lab run.
Rollout
Main's
config/supervisor-clearisoffuntil this lands; main removes it after the merge.