Make a scheduled job safe to run twice
A job that corrupts state if two instances overlap, made safe with a lock and a concurrency test.
The ticket
Make a scheduled job safe when two instances overlap.
Acceptance criteria
- Two concurrent runs produce the outcome of one
- A lock or a claim prevents overlapping work
- The lock expires so a crashed run does not block forever
- A test runs two instances concurrently and asserts one outcome
What lands as proof
A concurrency test running two instances at once and asserting a single outcome.
Why teams defer it
- Overlap only happens when a run is unusually slow, which is exactly when the damage is worst.
- Lock expiry is easy to get wrong, and a stuck lock is its own outage.
Questions
- What does the agent actually change?
- The ticket is scoped to one outcome: make a scheduled job safe when two instances overlap. Work that serves that outcome is in scope, and anything outside it is left for a separate ticket, so the pull request stays reviewable.
- How do I know the work is done?
- The pull request carries the evidence, not only the diff. Here that means concurrent-run test proving a single outcome, so a reviewer can confirm the result without reproducing the work locally.
- How much oversight does this need?
- The run stops once the plan is written. Somebody reads the approach and approves it before any code exists, which is the cheapest moment to redirect the work.