All guide activities

SD-12 · GUIDED WORKSHEET

Protect invariants under concurrency

Reserve the final seat without accepting two bookings.

Read. Try. Defend.

Companion to the Buildfest System Design guides.

Your practice brief

  1. Write the invariant and a conditional update or locking transaction.
  2. Show an interleaving of two clients and identify the loser response.
  3. Decide when payment occurs and how an expired reservation releases stock.

Your response stays in this tab. Download it before leaving. This self-guided worksheet is not graded or saved to your account.

Reveal reasoning after attempting

At most one reservation succeeds for the final unit when the database enforces the atomic condition. The other client must receive a clear outcome rather than guessing. Payment confirmation and reservation expiry need an explicit state machine and idempotent handling.

Other approaches can be valid. Check your assumptions, correctness, failure handling and trade-offs.