Urgent.News

What's breaking now, across thousands of outlets.

Tech

Node.js Reservation Expiry: Cron Timezone, Backfill, Pause-Resume, and Jitter Diagnostics

Short answer: treat a cron tick as a prompt to reconcile durable reservation deadlines, not as the event that makes a reservation expire. Store each deadline as an absolute UTC instant, claim due work idempotently, and keep a recovery cursor so a wrong timezone, missed run, pause-resume cycle, or a few seconds of jitter changes delivery latency rather than financial state. The hard constraint is…

A key aspect to understand is that a cron tick should be treated as a prompt to reconcile durable reservation deadlines, not as the event that makes a reservation expire. Each deadline should be stored as an absolute UTC instant, claimed idempotently, and a recovery cursor kept to handle issues like timezone errors, missed runs, pauses, resumptions, or minor timing discrepancies. The main concern is ensuring operational recovery, not just when the cron job runs.

For a reservation that holds for 15 minutes, the expiry time should be calculated once from the accepted reservation time and stored as a UTC instant. Repeatedly adding 15 minutes from the last scheduler run is incorrect, as it extends the hold period based on scheduler delays rather than the original deadline.

When troubleshooting, start with four timestamps: created_at, expires_at, claimed_at, and completed_at. The first two represent business state, while the latter two represent processing state. For instance, if reconciliation last completed at 10:02:11Z, execution paused, and resumed at 10:17:46Z, verify that the user's perceived time (like "9 AM") was correctly converted to the intended UTC instant at the system boundary.

The worker should query using expires_at = database_now, not a formatted date, and the pause should either record a scan cursor or keep the due rows queryable.

The recovery query should claim all still-open reservations whose persisted deadline is at or before the current database time. It doesn't need to replay imaginary runs for times between ticks, as those were mere opportunities to scan rather than actual business events. Finally, differentiate scheduler fire time, worker start time, and completion time; they are separate latency components, and conflating them as "jitter" obscures the actual failure mode.

For reservation expiry, schedule frequent reconciliation in UTC to avoid civil-time ambiguity. If user reminders require a local wall-clock promise, keep that presentation schedule separate from the reservation's absolute deadline. Remember, a single timestamp cannot safely represent both semantics; one system can legitimately have both, but the timestamps must not assume both.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

One Personal Token Was Holding Up 276 Terraform Workspaces

We moved Terraform Enterprise to a new home on EKS. The cutover went smoothly. Two days later, every pipeline in the organisation stopped producing runs at the same moment, and nobody got paged.

  • Single personal OAuth token caused outage for 276 Terraform workspaces
  • Token revocation due to GitHub's 10-token-per-user limit
  • Adopting GitHub App provides stable connection for all workspaces

More from Tuesday 13 October →