Idempotency: stopping the autumn duplicate run
One-line answer: Key design, locking and notification patterns that keep a job safe when the same wall clock appears twice.
When daylight saving ends, the same wall-clock time exists twice. If the scheduler fires on both, settlement, billing and notification jobs process data twice. The strongest defence is not a scheduler flag but idempotency: running twice must produce the same result.
Three ways to choose an idempotency key
| Key | Example | Trade-offs |
|---|---|---|
| Logical date | report:2026-11-01 | Absorbs the duplicate hour naturally; matches business meaning |
| Schedule instant + zone | 2026-11-01T01:30-04:00 | Precise, but the two occurrences get different keys |
| Input hash | sha256(input) | Allows reruns when data changes; costs computation |
For daily work, the logical date is the most practical. If that key has already been processed, the second run exits immediately. Store the record in a database unique index or an object-storage marker.
key = "report:" + logical_date_in_tz
if not claim(key): # already processed today
return
process()
mark_done(key)
Locking and timeouts
In a distributed system, claim the “in progress” state atomically: a conditional update such as UPDATE ... WHERE status='pending', or Redis SET NX. Always give the lock an expiry so a crashed process does not block tomorrow's run. If the expiry is shorter than the job's duration, duplicates come back, so set it at two to three times the expected runtime.
Notify last
A “done” notification sent midway through the job also fires on the second run. Send notifications after the transaction commits, and only when the idempotency key was newly created. External calls should carry a request ID so the receiver can deduplicate as well.
How to test it
Simulate the transition and run the job twice. Set the scheduler zone to America/New_York, register a 01:30 job, and trigger it before and after the first Sunday in November. Check the date in CronPulse's DST warning, then confirm in staging that the data changed only once.
In short
Preventing duplicate runs is application design, not scheduler configuration. Logical-date keys, atomic locks and post-commit notifications also protect you from retries and manual reruns.
Paste an expression and see its next run times right away.
Open CronPulseFrequently asked questions
Can't a scheduler option prevent duplicate runs?
Some schedulers offer a “fire once” option for the repeated hour, but behaviour varies by product and is not guaranteed. Retries and manual runs create duplicates anyway, so application idempotency is the final defence.
Where should the idempotency key live?
Wherever it can be written in the same transaction as the result. A relational unique index is simplest; object-storage markers suit large batch jobs.
Sources
Related reading
- Cron in five fields: minute, hour, day, month, weekdayWhat each of the five Unix cron fields means, which values are allowed, and how to read an expression without guessing.
- Cron special characters: *, /, -, commas, ?, L, W and #The eight symbols that make cron expressive, what each one means, and where implementations disagree.
- Five-field Unix cron versus six-field Quartz and EventBridgeSeconds, weekday numbers, the ? rule and the year field: what changes when you move a schedule between cron dialects.
- Daylight saving and cron: the day 02:30 disappearsHow clock changes affect cron runs, and how to move jobs out of the 2–3 AM danger window.