Repository navigation
test(tests): give re-arm recovery waits a budget that survives contended changed-suite runs - #5335
Merged
kunchenguid merged 1 commit intoSep 23, 2026
Conversation
The re-arm recovery cases judged "the watcher stayed live instead of surfacing recovery" with fixed budgets below what a real stale-lock recovery costs on a contended host: the arm's default 10s confirmation deadline, a start helper that returned after about 4s whether or not the arm had confirmed its watcher, and an 80-poll exit wait. A changed-suite run beside other suites starves the recovery's many short-lived processes while this suite's sleeping poll loops keep their pace, so a watcher still surfacing its recovery read as one that stayed live (issue kunchenguid#3793). The original 0.25s window after confirmation was widened to 80 polls in kunchenguid#3837, which left the same race at a larger size. Following the CONTRIBUTING.md fixture-budget rule, the re-arm helper now gives the arm an explicit 30s confirmation budget and waits for its confirmation or exit within a ceiling that outlasts it, and every wait on a re-armed watcher uses one named iteration-counted ceiling that outlasts the same budget. A passing case returns as soon as the arm reports or exits, and a watcher that never surfaces its recovery still fails. A new case delays every mktemp and readlink the re-armed watcher runs after it publishes its beacon, so its first poll and exit take about 13s on any host. It fails with the reported symptom on the previous budgets and passes now. No bin/ change.
Owner
|
Speaking as Kun's firstmate: this is merged. Thank you @tiago-peixoto — really appreciate you taking the time on this. Contract-class: restore. Tip vs main: VISION.md (per-rule)
Gates: CLEAN, CI green, NM green, attestation MATCH, safe. No Firstmate flag. No workflow approval. No security FYI. |
RajeshRajendiran
added a commit
to RajeshRajendiran/firstmate
that referenced
this pull request
Sep 23, 2026
Intent
Fixes #3793
The watcher recovery re-arm assertion fails in changed-suite runs while passing serially.
The issue reports that tests/fm-watch-arm.test.sh repeatedly fails its durable-recovery assertion in test_rearm_resurfaces_durable_queue_and_remote_open_decision ("not ok - re-arm stayed live instead of surfacing durable wakes and the still-open remote decision") during the runner's automatic changed-suite execution (bin/fm-test-run.sh --changed), while unchanged serial executions of the same suite (bin/fm-test-run.sh tests/fm-watch-arm.test.sh --jobs 1) pass. It blocks validation of otherwise unrelated contributions and needs attribution rather than being treated as a harmless retry. The report's evidence did not yet distinguish scheduler delay, interference from another selected suite, a fixture readiness race, or a production recovery defect, and it asked for a narrowly scoped reproduction and restoration of reliable recovery-test behavior.
Expected behavior: re-arming presents the retained durable wakes and the still-open remote decision within the test's bounded wait, while preserving the production recovery and acknowledgement contract. Any correction should retain the negative control that a genuinely absent recovery wake still fails.
The maintainer triage classed this as a restore: the suite already promises this assertion holds under the runner's normal changed-suite path, and the default validation path should not require an isolated serial rerun to pass. Help was wanted on attributing the changed-suite vs serial divergence without weakening the production recovery contract; a field incident becomes regression coverage.
What Changed
tests/fm-watch-arm.test.sh,start_rearm_armnow gives the arm an explicit 30s confirmation budget (FM_ARM_CONFIRM_TIMEOUT) instead of the 10s default. It also waits up to 700 polls for the arm to confirm its watcher or exit, where it used to give up after a fixed 80 polls (about 4s). Every re-armwait_for_exit, which used fixed 80- or 120-poll counts, now uses one named 400-poll ceiling that outlasts that budget. A passing case still returns as soon as the arm reports or exits, and a watcher that never surfaces its recovery still fails once the ceiling is spent. Nobin/code changes.test_slow_rearm_recovery_is_still_surfacedreproduces the loaded-host failure from tests/fm-watch-arm.test.sh: recovery re-arm assertion fails in changed-suite runs but passes serially #3793 on any machine. Once the re-armed watcher publishes its beacon, the case adds a 0.6s delay to everymktempandreadlinkcall it makes. The case then checks three things: the recovery wake and the queued wake are still surfaced and drained, the delay actually held the re-arm for at least 12s, and the wakes are acknowledged. The commit notes that this case failed with the reported "stayed live" symptom on the old budgets.docs/watcher-continuity.mdlists the new slow-recovery case in thefm-watch-armsuite's coverage description.Risk Assessment
✅ Low: The change only touches tests and one docs line, and does not modify any production recovery or acknowledgement code. It raises the arm's confirmation budget (FM_ARM_CONFIRM_TIMEOUT=30) and replaces the fixed 80/120-poll waits with iteration-counted ceilings sized above that budget: 700 x 0.05s in start_rearm_arm and 400 x 0.1s in wait_for_exit. It keeps the negative control: a watcher that stays live without surfacing its recovery still hits status 124 and fails. It also adds a regression case that slows mktemp and readlink after the successor's beacon is published, which reproduces the loaded-host divergence on any host.
Testing
This is a test-only fix for a flaky test, so the product surface is the repo's own test runner. I ran it on a host that was already heavily contended (load ~47-56 on 8 CPUs), which matches the issue's changed-suite conditions. Base vs fixed: the base re-arm assertion failed in 2 of 4 concurrent copies (the arm exited with status 1, before it could report the durable recovery) and the fixed version passed in all 4. The full changed-suite run (
--changed) passed in about 7m52s. The negative control, which removes the recovery evidence, still fails with "slow re-arm stayed live instead of surfacing its recovery", so a recovery wake that is genuinely missing still fails the test. One caveat: with the old 80-poll waits restored, the new slow-recovery regression case still passed on this loaded host. The test's own poll loop slows down under load too, so that case fails before the fix only on a less loaded host; I report this below as an informational note, not a failure. I cleaned up all temporary test copies.Evidence: Changed-suite runner transcript (pass under load)
Source: Changed-suite runner transcript (pass under load)
Evidence: Base re-arm assertion, 4 concurrent copies (2/4 fail)
Source: Base re-arm assertion, 4 concurrent copies (2/4 fail)
Evidence: Fixed re-arm assertion, 4 concurrent copies (4/4 pass)
Source: Fixed re-arm assertion, 4 concurrent copies (4/4 pass)
Evidence: Negative control: absent recovery still fails
Source: Negative control: absent recovery still fails
Evidence: Slow-recovery case with old waits restored (passed on this loaded host)
Source: Slow-recovery case with old waits restored (passed on this loaded host)
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
✅ **Review** - passed
✅ No issues found.
tests/fm-watch-arm.test.sh:391- The new test_slow_rearm_recovery_is_still_surfaced case goes red before the fix only on a lightly loaded host. Each wait_for_exit poll starts its own ps and sleep processes, so a busy host slows the old 80-poll wait along with the delayed recovery. At load ~50 on this host, the case passed with the old waits restored. The base-vs-fixed concurrent comparison of the original assertion did reproduce the bug (2/4 base failures vs 0/4 fixed), so the fix itself is demonstrated.bin/fm-test-run.sh --changed --base ada21f5(selects tests/fm-watch-arm.test.sh; full suite including the new slow-recovery case) on a host at load ~47-56 / 8 CPUsBase (ada21f5) test_rearm_resurfaces_durable_queue_and_remote_open_decision run as 4 concurrent copies (temporary filtered copy of the test file, since removed)New test_rearm_resurfaces_durable_queue_and_remote_open_decision run as 4 concurrent copies under the same loadNegative control: test_slow_rearm_recovery_is_still_surfaced with the dead watcher's lock, downtime marker and wake queue erased so no recovery wake existsCounterfactual: test_slow_rearm_recovery_is_still_surfaced with the old waits restored (80 polls, 10s confirmation)✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.