ADR-003: Make scheduled jobs misfire-aware and safe to repeat
Scheduled jobs use explicit misfire handling, bounded execution, and target-side idempotency so restarts, timeouts, and retries do not silently lose or duplicate business work.
1. Context & Problem
Service restarts, database interruptions, timeouts, or downstream outages can cause scheduled jobs to miss their planned execution windows or leave it uncertain whether a triggered task completed. Silently dropping missed runs risks leaving recurring maintenance undone, while replaying every missed interval or retrying endlessly can overwhelm downstream systems and create duplicate business effects. Each job needs an explicit recovery policy matched to its downstream contract.
2. Business Value
- System stability after outages: Prevents sudden traffic bursts after downtime by running a single recovery execution rather than replaying an entire backlog of missed intervals.
- Duplicate-safe reliability: Ensures recurring jobs can be safely re-run after interruptions without corrupting business data or repeating side effects.
- Bounded, predictable workloads: Keeps individual maintenance runs sized responsibly while preserving operational visibility into missed schedules and recovery attempts.
3. How It Works
- Every durable job defines an explicit missed-schedule recovery policy and keeps observable firing history. For recurring maintenance jobs, if one or more scheduled times are missed during an outage, the scheduler runs one prompt catch-up execution upon recovery instead of replaying every missed slot.
- Jobs that must not overlap are configured so two runs of the same job do not execute concurrently within the scheduler.
- Because restarts, timeouts, manual triggers, or downstream retries can still cause work to be requested more than once, receiving systems protect themselves with their own locks, duplicate detection, and durable work tracking.
- Per-run batch limits (such as capping email maintenance at 100 records per request) control load per invocation; any remaining eligible items stay queued for subsequent scheduled hourly runs rather than being lost.
- Retries remain bounded and visible, and a successful trigger handoff is never treated as proof that the downstream business task completed.
4. Trade-offs & Lessons Learned
- Single catch-up vs. full interval replay: Running once after a misfire avoids catch-up spikes, assuming missed recurring maintenance intervals do not each represent a distinct business event that must be replayed individually.
- Scheduler non-concurrency is not complete protection: Preventing overlapping runs inside the scheduler does not guard against manual invocations, other consumers, or target-side retries; target systems must still enforce duplicate-safe processing.
- Batch caps are not lifetime retry limits: A 100-record per-request cap controls single-run volume, not total backlog size or how many times an individual item is retried across future runs. Monitoring must track queue age, backlog, and per-item outcomes separately from trigger frequency.
- Alternatives considered:
- Replay every missed interval: Preserves nominal execution counts, but risks a burst of redundant catch-up work after downtime.
- Skip all missed executions: Avoids catch-up load, but silently loses scheduled maintenance opportunities.
- Rely only on scheduler-level non-concurrency: Cannot cover manual calls, external consumers, or downstream retries.
- Treat bounded batches as bounded retry policies: Confuses per-invocation work limits with per-record terminal failure rules.
5. Technical Reference
- Decision status: Accepted (
2026-10-27) - Applies to: Scheduler SystemSystemv1.0.0Scheduler SystemInternal Quartz-based platform system that persists schedules, coordinates recurring jobs, and dispatches background wor...Ownerplatform-engineering-teamDiagramOpen docs durable Quartz jobs.
- Misfire & concurrency policy:
- Current recurring jobs use
FireOnceNowfor misfires (making one execution eligible after a misfire without replaying every missed interval) and disallow concurrent executions. - Quartz persists misfire and execution history, but retry limits and idempotency belong to the specific job and target contract.
- Current recurring jobs use
- Target-side duplicate protection & batching:
- Catalog batch: Protected by its own database advisory lock and revision-aware queue acknowledgement.
- Notification maintenance: Handles at most 100 records per request; this batch limit is not a per-email lifetime retry limit, and unsent records remain eligible on later hourly runs.