Skip to main content

Durable workflows: exactly-once execution with checkpointing

Alex Blom

You charged the customer's card. Then the inventory API went down. The order is half done, and retrying from the top charges the card a second time. This video shows how checkpointing in the Tasks SDK gets every step of a workflow to run exactly once, no matter how many attempts the run takes.

What's covered

  • Why a plain retry makes a partial failure worse in a multi-step workflow
  • How aisle.checkpoint records finished steps so a retry skips them
  • A live demo with a planted failure in reserve_inventory that kills the first two runs
  • What auto retry in task settings does once the steps are checkpointed

The demo is a checkout with four steps that all have to happen: validate the order, charge the payment, reserve inventory, send the confirmation. Each step is wrapped in a checkpoint, so its result is stored the first time it succeeds:

charge = aisle.checkpoint.get_or_set(
    "charge_payment",
    lambda: charge_payment(order),
)

The checkpoint store is scoped to a run and its retries. A retry re-runs the whole script from the top, but a step that already finished returns its stored result instead of executing again.

In the video, reserve_inventory is rigged to fail on the first two attempts, which is what a flaky inventory API looks like. The first run validates the order, charges the card, and dies. With auto retry on, the second run skips both finished steps and fails at inventory again. The third run reserves inventory and sends the confirmation. The card was charged once across all three attempts.

The full checkpoint API, including aisle.parallel's built-in checkpointing for fan-out work, is in the concurrency and state docs.

Open Aisle →

Stay in the loop

Product updates, tutorials, and AI insights. No spam.