DEV Community

Morgan Ma
Morgan Ma

Posted on

Two Cron Runs, One Green Dashboard: A DST Debug Walkthrough

A daily report is scheduled for 02:30 in Europe/Berlin. On 25 October 2026 the local label 02:30 names two instants: 00:30 UTC and 01:30 UTC. Python's zoneinfo exposes the distinction through the fold attribute. Which one should produce the report? That is a scheduling contract, and the answer can differ between two jobs on the same machine.

Identify the intended slot

For one report per local business date, use the job name and intended local date as the business operation's identity, and specify which occurrence to run or how to handle a missing time in spring. For a job required at both real instants, use the scheduler's intended UTC instant to distinguish them. Do not compute a fresh slot from the worker's current clock on every retry: delayed execution across midnight can give the same invocation a second identity. A scheduler's timezone need not match the database session's timezone when both represent the chosen instant correctly.

Keep a record of delivery attempts separately from the business operation. Two scheduler notifications can map to the same operation. A unique business-slot constraint can prevent duplicate claims, but it cannot show how many attempts were rejected. Similarly, one claimed slot is not proof that its report finished. Record completion or an unresolved result as well.

Test a whole transition

Create fixtures for both UTC instants above and one benign date in summer. With a once-per-local-date policy expect two delivery records but one business identity on the transition. With a twice-per-instant policy expect two identities. Add a delayed redelivery and confirm it keeps the original slot. For the spring transition, use the chosen skip or catch-up rule to construct expected slots.

Compare expected slots with completed operations after the allowed delay. A missing result may mean no delivery, a failed job, or a job still running. Inspect the delivery history to distinguish them. Scheduler implementations have different policies, so validate the actual schedule and dispatch history alongside these application-level fixtures.

Python zoneinfo and fold ยท Kubernetes CronJob scheduling

This article was created with AI assistance.

Top comments (0)