Dead man's switches with a timeout under 15 minutes are only checked every 15 minutes #37

Open
opened 2026-10-09 12:42:37 +00:00 by niklas · 0 comments
Owner

Problem

POST/PUT /api/teams/{id}/deadman/switches accepts any timeout_seconds > 0, but sweepDeadman runs inside Sweep (internal/api/archiver.go), which ticks every sweepInterval = 15 * time.Minute. A switch with a 60s timeout is therefore detected up to timeout + 15m late, and the API gives no hint.

Why it is not a one-line fix

sweepDeadman returns the set of heartbeat alert ids that expireStale must skip, and the two run in one pass. Giving deadman its own faster loop means keeping that exemption correct (expiry must not resolve a heartbeat the switch loop owns).

Options

  • A scheduler with named tasks and per-task intervals (deadman ~30s, notifier 30s, sweeper 15m), each under its own advisory lock. This also fixes escalation never advancing when no ntfy URL is set (the notifier loop does not start without one).
  • Or enforce a minimum timeout (>= sweepInterval) and document it.

Acceptance

  • A switch with a short timeout opens its incident within roughly timeout + the new check interval.
  • Test using the existing back-dated received_at technique.
## Problem `POST/PUT /api/teams/{id}/deadman/switches` accepts any `timeout_seconds > 0`, but `sweepDeadman` runs inside `Sweep` (`internal/api/archiver.go`), which ticks every `sweepInterval = 15 * time.Minute`. A switch with a 60s timeout is therefore detected up to timeout + 15m late, and the API gives no hint. ## Why it is not a one-line fix `sweepDeadman` returns the set of heartbeat alert ids that `expireStale` must skip, and the two run in one pass. Giving deadman its own faster loop means keeping that exemption correct (expiry must not resolve a heartbeat the switch loop owns). ## Options - A scheduler with named tasks and per-task intervals (deadman ~30s, notifier 30s, sweeper 15m), each under its own advisory lock. This also fixes escalation never advancing when no ntfy URL is set (the notifier loop does not start without one). - Or enforce a minimum timeout (>= sweepInterval) and document it. ## Acceptance - A switch with a short timeout opens its incident within roughly timeout + the new check interval. - Test using the existing back-dated `received_at` technique.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: niklas/terdut-server#37