Restore an ICP timer schedule after a canister upgrade
A periodic worker needs a durable schedule because a canister upgrade clears its registered timers.
Persist the job position
Consider a worker that settles numbered batches every five minutes. Store the last completed batch and the next due timestamp in upgrade-safe state. Re-register the timer during upgrade initialization and decide explicitly whether an overdue batch should run immediately or be skipped.
stable state: next_due = 12:05, last_processed = 17
upgrade ends at 12:08
resume from job 18; schedule next wake-up
Handle a delayed wake-up
At 12:08 batch 18 is overdue. Acquire a durable claim before issuing an asynchronous payout and reconcile any prior pending claim. Timer scheduling provides wake-ups with variable delivery time. Exactly-once external settlement requires an application-level transaction identifier.