Index

Free, with Google

Keep going, free.

A free account opens lessons 2 and 3 of every track, 33 more lessons, and keeps your progress and review cards on every device.

Start free with Google

A chalk plan

Open everything on chalk.

Every lesson, board, video, lab and paper, and the full review decks. Yearly is $39/year.

See plansStart free instead

Module 09 · From Scratch · Distributed Scheduler · with code: Go · about 23 min to read

Play it as a journeyTutor comes with a plan

Scheduler 06: Idempotency and Fencing

Idempotency and Fencing
Idempotency and Fencing · Open board

The board that closes two problems the two boards before it opened and left running loose: Scheduler 05: Dispatch Queue, which guaranteed a job could be delivered more than once, and Scheduler 04: Leader Election, which let the machine in charge keep believing that after it no longer was. Hands off to Scheduler 07: The Hard Part, Time.

Before you start. This series builds a small scheduler: a program that runs jobs at set times across many machines instead of one, the way a single computer’s cron already does for one. Two things about it are already true. One machine at a time is elected leader, using a lease, a lock with a clock on it, so the right to give orders runs out on its own if nobody renews it. And a queue sits between the leader and the workers, and if a worker doesn’t answer back in time, the queue assumes the worst and hands the same job to someone else. Both are sensible, and both, pushed to their honest end, leave a crack open. This lesson closes it.

Lesson 67 of 117 in From Scratch

The rest of this lesson is part of a plan.

A plan opens every lesson, board, video, lab and paper on chalk. Yearly is $39/year.

See plansAlready a member? Sign in

Or start free: a free account opens lessons 2 and 3 of every track.

In this lesson

  • 2016: a blog post that ends a library’s honeymoon
  • Two ways to be wrong, and they are not the same bug
  • Idempotency: a name the job can’t fake
  • Fencing: a number that only climbs
  • Both at once: what happens when a zombie writes
  • The run-id, in code
  • The fencing token, in code
  • The zombie story, run three times
  • The honest boundary
  • What this closes

Terms it explains: The repeat, idempotency, The stale write, fencing, accepted, rejected, Delete the fence check, Delete the run-id check, Change `<` to `<=`, Against a real store, Stripe, Idempotent requests, Temporal, Activities.

Related papers

Review From Scratch