Repository navigation
fix(provider): probe an open circuit every 60 s - #376
Merged
Merged
Conversation
Once a provider's circuit opened, nothing closed it again. should_restart() returned false while circuit_open, the main loop skipped the provider, and only record_success() cleared the flag. An outage that outlasted the restart budget left the provider down until someone restarted the runtime. - While the circuit is open, the runtime makes one restart attempt (a half-open probe) every 60 s. ProviderSupervisor::should_probe() and record_probe_result() carry the schedule. A successful probe closes the circuit and keeps the crash streak until the provider stays healthy for success_reset_ms, so a crash right after a probe re-opens the circuit. A failed probe schedules the next one. A provider whose restart policy is disabled is never probed. supervision.circuit_open stays true until a probe succeeds. The interval is fixed, with no new config key. - restart_provider() stops the old process before it starts the replacement. It used to start the new provider first and drop the old handle only after the swap, so a provider that was unresponsive but still running (wedged on a hung bus) had a second process beside it for the whole restart, and for good when the restart failed. IProviderHandle gains stop(), which closes the session under the request mutex and shuts the process down. The stopped handle stays registered, so a failed restart is retried as before. - docs/providers.md documents the restart order and the probe interval. Tests: - Integration half_open_probe: the first launch crashes, the second fails to start, which spends a budget of one and opens the circuit; later launches are healthy. Before the change the provider never recovers (80 s timeout). After it, nothing relaunches during the first 5 s, and the provider is AVAILABLE with the circuit closed 60.1 s after it opened, after exactly one probe launch. - Integration wedged_restart: SIGSTOP the provider so it stays alive while every request times out, then count the runtime's live provider children until it recovers. Before the change two are alive at once; after it, never more than one. - ProviderSupervisorTest.OpenCircuitIsProbedOncePerInterval and DisabledPolicyIsNeverProbed pin the schedule with a 50 ms interval. Closes #326
CameronBrooks11
enabled auto-merge (squash)
October 15, 2026 20:18
CameronBrooks11
added a commit
that referenced
this pull request
Oct 16, 2026
) fix(provider): start the restart clock after the old process stops restart_provider() started its timeout clock before it stopped the old process (added in #376). Stopping a wedged provider takes up to runtime.shutdown_timeout_ms before the kill, so with restart_policy.timeout_ms below that, the attempt failed before the new process had started, and with max_attempts: 1 the circuit opened until the next 60 s probe. The clock now starts once stop() returns, so timeout_ms bounds the new process coming up, not the old one going down. docs/providers.md says so in the restart steps. Test: integration restart_timeout_excludes_stop. It suspends the provider with SIGSTOP (it stays alive while every request times out), with runtime.shutdown_timeout_ms 3000, restart timeout_ms 1500 and max_attempts 1, then waits 20 s for the provider to be AVAILABLE with devices on a new process and the circuit never open. - Before the fix: fails. The runtime logs "Restart timeout exceeded for provider 'provider-sim' after start() (3026ms >= 1500ms)" and the circuit opens. - After: passes (with wedged_restart, 9.3 s for both). - Moving the clock back above stop() fails this test alone; the other 9 supervision checks pass. Closes #379
CameronBrooks11
added a commit
that referenced
this pull request
Oct 16, 2026
Bumps `project(VERSION)` and `vcpkg.json` to 0.1.45 and rolls the CHANGELOG. Ships, among others: - `safety.on_startup`, default `safe_state`: the declared safe state runs once at every runtime start (#392, closes #362); - Grafana and InfluxDB bound to loopback under `--with-observability`, with `--with-grafana-network` to open Grafana to the LAN (#359, closes #351); - `install.sh` refuses a downgrade unless `--allow-downgrade` (#382, closes #366); - the zero rung no longer sends a guessed boolean (#367), e-stop `safe_state_achieved` (#368), dispatchable coverage counts (#369), and startup warnings for fault-hook gaps (#370) and disarmed watchdogs (#371); - `health.excluded_signals` (#377), signal unit and description in capabilities (#365); - a half-open probe of an open provider circuit every 60 s, a restart that stops the old process first, and a restart clock that starts after it stops (#376, #391); - automation status: `idle` outside AUTO, and `failed` cleared by a load or a new AUTO run (#373, #386); - `install.sh`: provider liveness in the health phase (#355, #383), `manifest.json` restored on `--rollback` (#354), Grafana restarted on every observability run (#343), the datasource debug lines filtered from the journal (#360), and the uninstall prefix guard (#342); - no ERROR lines for reads that fail during shutdown (#381). The CHANGELOG opens 0.1.45 with upgrade notes: Grafana is on loopback by default, `safety.on_startup` drives outputs at boot by default, and downgrades need `--allow-downgrade`. The 0.1.44 note about restarting grafana-server by hand is not repeated, since #343 restarts it on every run. The OpenAPI changes are additive: `SignalSpec.unit` and `.description`, `EstopResponse.safe_state_achieved`, `ParameterDefinition.source` and the runtime status `startup_safe_state`. No provider-protocol change. anolis-workbench vendors the OpenAPI file and needs a repin to this release. Every commit in `git log v0.1.44..main` is in the CHANGELOG except CI, test-only and docs-lint commits (#380, #384, #389). After merge, tag `v0.1.45`.
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.
fix(provider): probe an open circuit every 60 s
Once a provider's circuit opened, nothing closed it again.
should_restart() returned false while circuit_open, the main loop
skipped the provider, and only record_success() cleared the flag. An
outage that outlasted the restart budget left the provider down until
someone restarted the runtime.
half-open probe) every 60 s. ProviderSupervisor::should_probe() and
record_probe_result() carry the schedule. A successful probe closes
the circuit and keeps the crash streak until the provider stays
healthy for success_reset_ms, so a crash right after a probe
re-opens the circuit. A failed probe schedules the next one. A
provider whose restart policy is disabled is never probed.
supervision.circuit_open stays true until a probe succeeds. The
interval is fixed, with no new config key.
replacement. It used to start the new provider first and drop the
old handle only after the swap, so a provider that was unresponsive
but still running (wedged on a hung bus) had a second process beside
it for the whole restart, and for good when the restart failed.
IProviderHandle gains stop(), which closes the session under the
request mutex and shuts the process down. The stopped handle stays
registered, so a failed restart is retried as before.
interval.
Tests:
fails to start, which spends a budget of one and opens the circuit;
later launches are healthy. Before the change the provider never
recovers (80 s timeout). After it, nothing relaunches during the
first 5 s, and the provider is AVAILABLE with the circuit closed
60.1 s after it opened, after exactly one probe launch.
while every request times out, then count the runtime's live
provider children until it recovers. Before the change two are
alive at once; after it, never more than one.
DisabledPolicyIsNeverProbed pin the schedule with a 50 ms interval.
Closes #326