Mid-level Track Roadmap

Idempotent background jobs

This course works through how to make a background job safe to run more than once, using Partners::FetchSiteIconJob as the running example. It compares a guard checked at enqueue time with one checked inside perform. It then covers three tools for a single step: a state check, a unique index with create_or_find_by!, and absolute writes. A hypothetical second step shows where one guard breaks. The course then adds a reservation row written before the side effect, step ordering, and HTTP GET versus POST with a deduplication key.

What you'll learn

  • ✓Why a guard inside perform protects retries and an enqueue-time check does not
  • ✓Three ways to make one step safe to redo: state checks, unique indexes and absolute writes
  • ✓Tracing every crash point between two effects in a job
  • ✓Guarding a step with a reservation row under a unique index, written before the side effect
  • ✓Why placing the least-safe step last limits damage from a missing guard
  • ✓How GET differs from external POST requests that need a deduplication key
Free preview · Lesson 1 4 min read

One guard was never the whole job

Two courses already pointed here by name. The mid-level course "Pattern: idempotency keys" built a reserve, work, complete guard around a whole operation, and closed by describing this one: "That course asks a harder question: how to design a job so it's safe to retry any number of times, including…

Read the full lesson free →

Curriculum

7 lessons
Type to start searching...