Skip to content

Re-arm the breaker's recovery timer instead of giving up - #18

Merged
fylorn merged 1 commit into
mainfrom
fix/breaker-recovery-timer
Sep 15, 2026
Merged

fylorn merged 1 commit into
mainfrom
fix/breaker-recovery-timer

Conversation

@fylorn

@fylorn fylorn commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Follow-up to #17, fixing a hole in the recovery half of HealthChanged.

The bug

Every failure past the threshold pushes opened_at out to now, and failures keep arriving while a breaker is open — with all candidates open the gateway fails open and tries them anyway. The one-shot timer armed when the breaker tripped would wake, see a cooldown that had been pushed past it, say nothing, and exit. Nothing was left to announce the moment the breaker became ready to probe again.

The visible result is the two views disagreeing: /overview computes the state fresh and reports ok as soon as the cooldown elapses, while a client following the event stream still shows the provider as tripped until some request happens to hit it.

The fix

The timer re-arms. Health::cooldown_left distinguishes the three cases it can wake into — no longer tripped (a success already announced it), cooldown elapsed (announce), pushed back (sleep the remainder and look again) — replacing the one-shot just_cooled_down.

Gates

cargo fmt --all -- --check, cargo clippy --workspace --all-targets -- -D warnings, cargo test --workspace (61 binaries green), ./scripts/smoke.sh (46 passed, 0 failed).

🤖 Generated with Claude Code

Every failure past the threshold pushes the cooldown out to now — and
while a breaker is open, failures keep arriving: with all candidates
open the gateway fails open and tries them anyway. So the one-shot
timer armed when the breaker tripped would wake up, see a cooldown
that had been pushed past it, say nothing, and exit. Nothing was left
to announce the moment the breaker actually became ready to probe.

The visible result is worse than a missing event: the pushed view and
the polled view disagree. `/overview` computes the state fresh, so it
reports `ok` as soon as the cooldown elapses, while a client following
the event stream still shows the provider as tripped — until some
request happens to hit it.

The timer now re-arms instead of giving up. Health::cooldown_left
tells it which of the three cases it woke into: no longer tripped (a
success already announced the recovery), cooldown elapsed (announce
it), or pushed back (sleep the remainder and look again).

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

Thanks for the PR. One thing before review: this targets main, and it should target dev.

main is a release-only line — branch-protected, linear history, and every commit on it is a tagged release snapshot. Routine work lands on dev and reaches main with the next release. GitHub pre-filled main here because it is the default branch, so this is our defaults being unhelpful rather than anything you did wrong.

No need to close and reopen: click Edit next to the PR title and change the base branch to dev. The commits and the discussion carry over.

See CONTRIBUTING.md and CONTRIBUTING.md for the branch contract.

@fylorn
fylorn merged commit bc90267 into main Sep 15, 2026
2 checks passed
@fylorn
fylorn deleted the fix/breaker-recovery-timer branch September 15, 2026 09:58
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.

1 participant