Migrate a scheduled job
Latest stable Based on Leader release 0.4.0
Add election around an idempotent job without mistaking it for durable scheduling.
Before wrapping
Section titled “Before wrapping”Give the job a stable logical name, make its effects idempotent, record durable progress, and decide whether a missed run should be skipped, retried, or backfilled. Leader election only coordinates concurrent attempts; it does not persist a schedule.
Wrap and size
Section titled “Wrap and size”Place only the mutually exclusive section inside runIfLeader. Keep unrelated preparation outside when safe. Derive lease time from measured execution and add an idempotency key to external writes. If one run can exceed the lease, enable a supported extension path or split the work.
Rollout
Section titled “Rollout”Deploy first with metrics and no destructive cleanup. Confirm one elected event per schedule, expected skips on other nodes, bounded duration, and clean release. Rehearse leader termination. For Quartz, Spring Batch, or another durable scheduler, keep its recovery semantics and use election only where cross-instance exclusion is still needed.