Add a 5-minute circuit breaker for open data 503 responses #38

Merged
eraviart merged 1 commit from fix/open-data-503-circuit-breaker into master 2026-10-06 12:42:03 +02:00
Owner

Motivation

During the 2026-10-05/06 open data outage, data.assemblee-nationale.fr answered 503 Backend fetch failed (Varnish could not reach its origin). Our tooling then added avoidable load to the struggling front end:

  • the watcher re-probed failing datasets every 30–60 s, each check firing 6 cache-busted HEAD probes (~30 requests/min peaks in the 10:17–10:26 logs);
  • download retries fired every few seconds while the server answered 503 immediately.

Change

src/open_data/artifacts.ts now keeps a process-wide circuit breaker shared by artifact probes and downloads:

  • the first HTTP 503 opens the breaker for 5 minutes (sliding: each 503 restarts the cooldown);
  • while open, any further probe or download request waits out the remaining cooldown before being sent (it does not fail: downloads keep their resume/budget semantics and simply proceed once the cooldown elapses);
  • other failures (timeouts, 4xx, 5xx other than 503) keep the existing per-request retry behaviour;
  • the transition to open is logged as a JSON circuit-breaker-open event;
  • calls can tune or disable it with the new circuitBreakerCooldownMs option (0 disables).

Net effect during an outage: at most one probe burst and one download attempt per 5 minutes per process, instead of bursts every 30–60 s.

Tests

  • 503 probe trips the breaker and the next probe waits out the cooldown;
  • non-503 errors do not open it;
  • download requests are spaced by the remaining cooldown (deterministic fake clock).

The existing retry-budget test now disables the breaker explicitly (circuitBreakerCooldownMs: 0).

## Motivation During the 2026-10-05/06 open data outage, `data.assemblee-nationale.fr` answered `503 Backend fetch failed` (Varnish could not reach its origin). Our tooling then added avoidable load to the struggling front end: - the watcher re-probed failing datasets every 30–60 s, each check firing 6 cache-busted HEAD probes (~30 requests/min peaks in the 10:17–10:26 logs); - download retries fired every few seconds while the server answered 503 immediately. ## Change `src/open_data/artifacts.ts` now keeps a process-wide circuit breaker shared by artifact probes and downloads: - the first **HTTP 503** opens the breaker for **5 minutes** (sliding: each 503 restarts the cooldown); - while open, any further probe or download request waits out the remaining cooldown before being sent (it does not fail: downloads keep their resume/budget semantics and simply proceed once the cooldown elapses); - other failures (timeouts, 4xx, 5xx other than 503) keep the existing per-request retry behaviour; - the transition to open is logged as a JSON `circuit-breaker-open` event; - calls can tune or disable it with the new `circuitBreakerCooldownMs` option (0 disables). Net effect during an outage: at most one probe burst and one download attempt per 5 minutes per process, instead of bursts every 30–60 s. ## Tests - 503 probe trips the breaker and the next probe waits out the cooldown; - non-503 errors do not open it; - download requests are spaced by the remaining cooldown (deterministic fake clock). The existing retry-budget test now disables the breaker explicitly (`circuitBreakerCooldownMs: 0`).
An HTTP 503 from the open data front end (Varnish 'Backend fetch
failed') means its origin is failing. Retrying probes every 30-60s
and download attempts every few seconds then only adds load to a
struggling server.

Probe and download requests now share a process-wide circuit breaker:
the first 503 opens it for 5 minutes (sliding), and any further probe
or download request waits out the remaining cooldown before being
sent. Other failures (timeouts, 5xx other than 503, 4xx) keep the
existing per-request retry behaviour. Disable or tune it per call
with the new circuitBreakerCooldownMs option (0 disables).
eraviart merged commit 9a09831e63 into master 2026-10-06 12:42:03 +02:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
logiciels/tricoteuses-assemblee!38
No description provided.