Workshop index · Download all examples and lessons
Time: 40 minutes. Prerequisite: lesson 5. Outcome: a concrete failure trace involving more than one component.
Open the retry exercise. The client retries a timeout once. That sounds reasonable, but a timeout says the client did not receive a response; it does not tell you whether the server changed state.
Trace the sequence
Read the client, the response-loss transport, and the store. Write the sequence of events for a two-seat request against capacity five. Mark the moment the reservation is accepted and the later moment the client sees a timeout.
Run the demo and compare its output with your prediction. Turn your prediction into a test that checks accepted bookings and the returned response, not merely whether the call succeeds.
Ask an assistant, if available:
Trace the first attempt and retry using the same request key. Where is that key enforced? Show the stored state after each call. Do not assume that a timeout rolls back server state.
TypeScript: an additional interleaving
The TypeScript demo also starts two requests against a two-seat workshop. Both want two seats. Draw this schedule:
A reads capacity → A waits
B reads capacity → B waits
A writes booking → B writes booking Count total accepted seats as well as final availability. The latter can look valid despite overbooking. JavaScript’s single-threaded execution does not prevent stale observations across an await.
Python readers can study the same schedule conceptually; the supplied Python store makes no concurrency claim. Do not use a passing sequential test as evidence of concurrency safety.
Independent task
Write a review comment that names the reachable sequence and its consequence. Identify which component must enforce the invariant. Compare these possible fixes: remove retries, reuse a request key, or enforce that key at the reservation boundary. Explain which is sufficient under this contract.
Hint
The request key is already reused. Passing an identifier through the client does not make a write idempotent unless the state-changing component checks it.
Checkpoint
You can reproduce duplicate reservations, explain the cross-component cause, and state the reference fix’s limits. TypeScript readers should also demonstrate the deterministic interleaving. Compare with the solution, then continue to reviewing the follow-up.
← 5. Turn a suspicion into a meaningful regression test · 7. Write the review, then review the response →