Wiederholungen mit Backoff, Dead Letters, Einblick in hängende Jobs.
Spec — Background job queue
Status: draft · Created: 2026-11-10
1. Context and goal
Slow or unreliable work runs in workers outside the request, finishes even when a worker dies, and fails visibly instead of silently.
2. Functional requirements (EARS)
- FR-1: WHEN a job is enqueued, THE SYSTEM SHALL persist it with its type, payload, attempt count and run-at time before acknowledging, so no job is lost on a restart.
- FR-2: THE SYSTEM SHALL hand each job to one worker at a time under a lease of 5 minutes that the worker renews while the job runs.
- FR-3: IF a worker dies or lets its lease expire, THEN THE SYSTEM SHALL make the job available again within 1 minute of the expiry.
- FR-4: IF a job fails with a retryable error, THEN THE SYSTEM SHALL retry it with exponential backoff and jitter from 10 seconds, up to 8 attempts unless its job type sets another number.
- FR-5: IF a job uses up its attempts or fails with a non-retryable error, THEN THE SYSTEM SHALL move it to a dead-letter list with the last error and stack trace.
- FR-6: WHEN an operator retries or discards a dead-letter job, THE SYSTEM SHALL do so and record who did it and when.
- FR-7: THE SYSTEM SHALL show per job type the queued, running, failed and dead-letter counts and the age of the oldest queued job, and alert when that age exceeds 10 minutes.
- FR-8: WHERE a job type has a concurrency limit, THE SYSTEM SHALL never run more of its jobs at once than that limit.
3. Out of scope
- Recurring schedules of the cron kind.
- Workflows that chain several jobs.