← Blog · Guides

Can Your Job Safely Run Twice? A 10-Minute Idempotency Audit for Scheduled and Queued Work

November 25, 2026

Every scheduled or queued job eventually runs more often than you meant it to. A retry after a timeout, a cron entry that fires while the last run is still going, a worker that crashes after doing the work but before recording it, a teammate who presses "run now" to test. The question is not whether a job will run twice. It is which of your jobs would be wrong if it did.

This article is a short audit you can run on your own jobs: list each step that changes something outside your process, ask what a second run would do, and pick the cheapest fix.

Why this came up this week

On 25 November 2026 Vercel released Workflow SDK 5.8 with a new execution engine. Its changelog (read 26 November 2026) says that many of the speed gains rely on speculative execution of steps, which applies only to steps that are retryable, and that new runs use the new engine by default once you upgrade. Vercel is explicit about the condition. Its wording: "Only Steps that are idempotent can be run in this way", and a step that is sensitive and can't be retried should be marked maxRetries = 0 to opt out, so that it still runs at most once.

The speed figures are Vercel's own benchmarks of 5.2.0 against 5.8.0, not a measurement of anyone's workload: p75 step-to-step overhead fell from 85 ms to 7 ms, and a fan-out of 256 parallel steps added 2.5 seconds of overhead instead of 13.5. The 5.2.0 step-overhead and resume figures were measured on 12 November 2026; the rest on 24 November 2026.

That is a reasonable, well-documented trade. It also puts the correctness question where it always was: with the person who wrote the step. Vercel's own example shows both sides. A Stripe charge that passes the step's ID as an idempotency key is already safe, because Stripe creates one charge however many times the call is made. A receipt email sent over SMTP is the hard case, because SMTP has no idempotency key, so Vercel's example opts that step out with maxRetries = 0.

You do not need to use Vercel for any of this to apply. Retries, overlapping cron runs and queue redeliveries all produce the same second run.

The audit

Go through your scheduled and queued jobs and list every step that does one of the things below. For each, the left column is what "ran twice" looks like, and the right is the cheapest fix that usually works.

The stepIf it runs twiceCheapest fix
Charge or refund a cardTwo charges, or two refundsPass an idempotency key the provider supports, derived from something stable such as the order ID
Send an email or SMSThe customer gets it twiceRecord "sent" against a natural key (order ID + message type) before sending, and skip if present; or opt the step out of retries
Post to a webhook or third-party API with no idempotency keyThe other side acts twiceSend a stable event ID so the receiver can dedupe, or record the call in a dedupe table first
Increment a counter or balanceThe number is off by one each timeStore the event with a unique key and compute the total from events, instead of adding in place
Insert a rowA duplicate rowA unique constraint on the natural key, with "insert or ignore" / "on conflict do nothing"
Write or append to a fileA duplicated line, or a half-written file read by someone elseWrite to a temporary name and rename it into place; never append to a shared file from a job that can retry

Anything not on this list (reading data, computing a result, rendering a report that overwrites the previous one) is usually safe to repeat already.

The four fixes, in order of preference

1. A natural key the database enforces

If the thing you are creating has a real identity, such as an invoice for one customer for one month, make that identity a unique key. A second run then fails cleanly or does nothing:

-- MySQL
INSERT IGNORE INTO invoices (account_id, period, amount)
VALUES (?, '2026-11', ?);

-- PostgreSQL
INSERT INTO invoices (account_id, period, amount)
VALUES ($1, '2026-11', $2)
ON CONFLICT (account_id, period) DO NOTHING;

2. An idempotency key the other side honours

Payment providers and many APIs accept a key with each request and return the original result if they see it again. The key has to be stable across attempts: derive it from the order ID or the step's ID, never from a timestamp or a fresh random value, or every retry looks new.

3. A dedupe table you own

For things the other side cannot dedupe, such as SMTP, SMS and most webhooks, record the intent first under a unique key, and only act if the insert succeeded. This narrows the window to "crashed between recording and sending", which is usually the failure you would rather have: a missing email you can resend, not a duplicate you cannot recall.

4. Opt the step out of retries

When none of the above is practical, turn retries off for that one step, as Vercel's maxRetries = 0 does, and accept that a failure now needs a person. Do this for the few steps that need it, not the whole job.

The cron case: overlap

Cron starts a job on schedule whether or not the previous run has finished. A job scheduled every five minutes that sometimes takes seven will run twice at once. The audit above covers the steps; for the job as a whole, a lock is the simplest guard. On Linux, flock skips a run if the last one still holds the lock:

*/5 * * * * flock -n /tmp/sync.lock php artisan app:sync

Laravel's scheduler has the same guard built in as ->withoutOverlapping(). On DeployBase, cron entries are standard five-field schedules that start the command on time whether or not the previous run has finished, so this applies to them as to any crontab.

We covered a different question about scheduled jobs earlier this month, where a schedule's definition lives and who can change it. This one is whether the job is safe to run more than once. They are worth asking together.

Ten minutes this week

  1. List your scheduled and queued jobs.
  2. Mark every step that charges, sends, posts, increments, inserts or writes.
  3. For each marked step, write down which of the four fixes it has. A blank means a second run is a bug waiting for a retry.

Source: Vercel changelog, "Workflow is 10x faster, again" (published 25 November 2026, read 26 November 2026). All performance figures quoted are Vercel's own benchmarks.