# 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.

Category: Queues, jobs, and async work
Source: https://letsship.ai/use-cases/make-a-scheduled-job-safe-to-run-twice
Published: 2026-08-25

## Goal

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.

## Prompt

Copy this to an agent to open the ticket:

```text
Create a Linear issue in my team and assign it to the SHIP agent.

Title: Make the {job} job safe to run concurrently

Description: 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

Before you create the issue, find a scheduled job in this repository with no overlap protection and replace {job}.
```

## 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.
