Skip to content

Circuit Breaker

Sublarr wraps every subtitle provider call in a circuit breaker. When a provider starts failing repeatedly, the circuit breaker opens and prevents further requests until the provider has had time to recover. This stops cascade timeouts from blocking your entire download queue.

CLOSED ──(5 consecutive failures)──► OPEN
▲ │
│ (300 s cooldown)
│ ▼
└────(probe succeeds)────── HALF_OPEN
probe fails ──► OPEN
StateMeaningRequests allowed
CLOSEDNormal operation, failures are countedYes
OPENProvider assumed down, calls are rejected immediatelyNo
HALF_OPENCooldown elapsed — one probe request allowed throughOne probe
FromToTrigger
CLOSEDOPEN5 consecutive failures
OPENHALF_OPEN300 seconds have elapsed since last failure
HALF_OPENCLOSEDProbe call succeeded
HALF_OPENOPENProbe call failed
AnyCLOSEDManual reset via API

Circuit breaker thresholds are global defaults. Future releases will expose per-provider overrides.

ParameterDefaultDescription
failure_threshold5Consecutive failures before opening
cooldown_seconds300Seconds to wait before allowing a probe

Circuit breaker state (open/closed, failure count, last failure time) is persisted in the circuit_breaker_state database table. After a restart, the breaker restores its previous state. If the breaker was OPEN and the cooldown has already elapsed at restart time, it immediately transitions to HALF_OPEN so the first real request acts as the probe — no extra wait.

Each provider’s circuit breaker exposes metrics at GET /api/v1/metrics:

MetricDescription
sublarr_circuit_breaker_stateCurrent state as a label (closed, open, half_open)
sublarr_circuit_breaker_failure_countCurrent consecutive failure count

Use these metrics in Grafana or Prometheus alerts to detect providers that are repeatedly tripping their circuit breakers.

If a provider’s circuit breaker is OPEN and you want to force an immediate retry without waiting for the cooldown:

  1. Go to Settings → Providers
  2. Find the provider with the “Circuit Open” badge
  3. Click Reset (or Re-enable depending on UI version)

This calls the internal reset() method, which immediately transitions the breaker to CLOSED and persists the new state.

Alternatively, via API:

Terminal window
curl -X POST http://<HOST_IP>:5765/api/v1/providers/<PROVIDER_NAME>/reset \
-H "X-Api-Key: <API_KEY>"

Providers are auto-disabled (circuit opened) when:

  • They return repeated HTTP errors (4xx/5xx)
  • They time out repeatedly
  • Their response cannot be parsed
  • Authentication errors (401/403) are returned repeatedly

A single failure does not open the circuit. Five consecutive failures are required (default threshold). A single success resets the failure counter.