Skip to content

fix(remote): back off a failing host instead of retrying forever - #226

Merged
devsuitup merged 1 commit into
mainfrom
fix/remote-refresh-backoff
Sep 8, 2026
Merged

devsuitup merged 1 commit into
mainfrom
fix/remote-refresh-backoff

Conversation

@devsuitup

Copy link
Copy Markdown
Owner

Closes #215.

A live install logged 226 consecutive identical failed cycles over ~19 hours,
at exactly 300.0 s apart, with nothing slowing down, giving up, or surfacing.
Only restarting the app ended it. That particular cause is fixed; the absence of
a circuit breaker was not.

Per-host exponential backoff: intervalMs * 2^(failures-1), capped at 30
minutes. The cap stays short so a host that comes back is picked up without any
intervention. The first success resets the counter and the delay immediately.

A failing host is slowed, never disabled. Disabling would mean touching the
enabled flag the UI owns, turning a transient network problem into a silent and
permanent loss of mirroring — the same failure class this issue is about.

Logging is no longer uniform: a line is written on the first failure and at each
tier change, plus one on recovery. Known trade-off: once the delay reaches the
cap it stops changing, so a permanently failing host goes quiet. The state stays
queryable through the new accessor and #218 will surface it.

State is exposed per host — consecutive failures, last error, next attempt — in
the same spirit as the existing session accessor. No UI change here.

Verification

Three mutations, each with the changed line printed before the run and the file
restored from an md5-verified copy:

  1. Cap removed → the cap test fails (1920000 vs 1800000).
  2. Failure counter no longer reset on success → the recovery test fails (3 vs 0).
  3. A host in backoff breaks the loop instead of skipping → the isolation test
    fails, the healthy host refreshing once instead of twice.

Clock and transport are injected; no network, no real ssh.

task check: 1123 tests, 1115 passed, 0 failed, 8 pre-existing skips. Lint 0
errors.

… fixed cadence

A dead host previously reran the ssh inventory every fixed interval forever;
one field log carries 226 identical "transport disposed" warnings, one every
300.0 s, over ~19 h with nothing ever slowing it down or surfacing it.

refreshNow() now tracks consecutive failures per alias and delays the next
attempt by min(intervalMs * 2^(failures-1), 30 min): base equals the host's
own configured cadence so an isolated blip costs nothing extra, and 30 min
was chosen as a ceiling short enough that a recovered host is picked back up
without anyone restarting the app. A host past its next-attempt instant is
skipped for that cycle only, no ssh call, no log line, while its peers still
run on schedule. One success resets the counter and delay to nominal
immediately.

Decision: a permanently failing host is only slowed to the 30 min ceiling,
never disabled, disabling would need the same enabled flag Settings owns,
turning a transient network problem into a silent, permanent loss of
mirroring with no UI to notice or undo it, whereas one capped attempt per
30 min is cheap enough to just keep paying.

Failure logging is throttled to the first failure and each change of tier,
not every attempt. Per-host state (consecutive failures, last error, next
attempt instant) is readable via getRemoteHostState(alias).

Refs #215
@devsuitup
devsuitup enabled auto-merge (squash) September 8, 2026 12:34
@devsuitup
devsuitup merged commit d2a5338 into main Sep 8, 2026
9 checks passed
@devsuitup
devsuitup deleted the fix/remote-refresh-backoff branch September 8, 2026 12:39
@devsuitup devsuitup mentioned this pull request Sep 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(remote): a failing host retries forever with no backoff

1 participant