LearnastraTHE DESIGN COURSE

Think like a designer / CHAPTER 06

Common interview mistakes and how to recover

Recognize reasoning traps early and recover by reconnecting the design to its requirements.

Beginner1h of deliberate study10 questions

Builds on A practical system design template.

By the end, you can
  • Identify premature complexity and unsupported guarantees.
  • Correct a design after discovering a broken assumption.
  • Communicate uncertainty without abandoning the discussion.

01Recognize a reasoning mistake, not just a missing box

Two people see the same green seat on a cached concert map. Both try to buy it. The design must decide who owns the seat and what happens to each payment.

Consider this flawed answer: “Put the purchase in a queue and retry after a timeout; the queue processes it exactly once.” Identify what is missing:

  • A green map entry can be old. It does not reserve the seat for either buyer.
  • A queue stores work for a worker to process later. Accepting that work does not mean the seat was acquired or payment completed.
  • A payment may succeed before its response is lost. A timeout does not prove that no money moved.

Start the repair with the seat record:

  1. Ask the inventory service to claim the seat only while its saved state is available.
  2. Make the database check and claim one indivisible operation, so two buyers cannot both win from the same old value.
  3. Return a defined conflict to the loser instead of promising a purchase from the map.

This is a conditional reservation: the saved condition must still hold when the claim is accepted. A familiar cache, queue or database name does not replace this operation.

02Repair the failure timeline

Let the winning buyer’s seat reservation be R12. Let P9 identify this intended payment, so every repeat can refer to the same payment rather than create another.

A queue consumer is the worker receiving the task; the broker is the system delivering it. Follow the dangerous sequence:

  1. The worker receives payment task P9.
  2. The provider charges successfully.
  3. The worker crashes before saving the payment result or acknowledging completion to the broker.
  4. The broker delivers P9 again because it did not receive completion.

The next attempt must check saved state and use the provider’s supported retry behavior:

  1. Look up the payment record for P9. If a completed result is already saved, return it without starting another charge.
  2. If the result is missing or uncertain, retry or query the provider using that same supported payment identifier.
  3. Save the known result, or save pending status and the provider reference while it is being resolved.
  4. Acknowledge the queued work only after the payment record contains either the final result or a pending result that a recovery worker can find and resolve using P9. A crash must not leave the only recovery instruction in this worker’s memory.

A local “processed” flag alone cannot cover the provider call. Saving it before charging can lose a payment; saving it after charging leaves the crash gap above. Check how the provider deduplicates identifiers, how long it remembers them and how status can be queried. If it offers no suitable guarantee, state the remaining duplicate/uncertainty risk honestly.

The broker may deliver a task again: this is at-least-once delivery. A repeated operation with the same intended effect is idempotent. These are different properties.

03Recover clearly and avoid three other traps

Reservation expiry changes what recovery may do. A delayed payment cannot simply recreate ownership of a seat sold to somebody else:

  1. Read the current seat owner and reservation state.
  2. Resolve P9 with the provider instead of assuming the timeout means failure.
  3. If the provider confirms payment, use an inventory transaction to check that this buyer still owns the unexpired reservation and mark that booking confirmed together. If payment definitively failed, record the failure and release only this buyer’s reservation.
  4. If money moved without a valid seat claim, record the product’s compensation, such as a refund. Do not confirm a second owner.

Comparing saved purchase state with the provider’s actual result and completing missing steps is reconciliation. Returning money after an irreversible step cannot be kept is one possible compensation.

Repair other interview mistakes with equally specific work:

  • If you used a fleet average, inspect the busiest show and what happens after one machine fails.
  • If database isolation is unfamiliar, state the required reservation behavior and verify the supported operation.
  • If a private read lacks permission checks, add the check before byte delivery and test revoked access.
  • If you propose another service, identify the concrete capacity or responsibility it improves and the new network failure it creates.

After a correction, rerun the original failure:

  1. Race two buyers for the seat.
  2. Lose a charge response.
  3. Redeliver the same payment task.
  4. Let the reservation expire while payment is uncertain.
  5. Verify one accepted owner and the intended payment or recorded compensation.

A useful explanation identifies the changed record and checked condition. Naming “exactly once” without those steps leaves the flaw in place.

Find the duplicate-charge boundary

Find the duplicate-charge boundaryFollow the successful charge before the crash. The queue can redeliver P9 even though the provider already charged it. Resolve the same payment identity and reconcile ambiguous business state. Numbered arrows correspond to the connection key below. All connections are directional.Payment P9Queue deliveryProvider chargeEffect succeedsConsumer crashesBefore completion isrecordedP9 returnsSame messagedelivered againRecover paymentP9Retry or query thesame provider IDResolve theresultSave charge orrequired refund12345Find the duplicate-charge boundaryFollow the successful charge before the crash. The queue can redeliver P9 even though the provider already charged it. Resolve the same payment identity and reconcile ambiguous business state. Numbered arrows correspond to the connection key below. All connections are directional.Payment P9Queue deliveryProvider chargeEffect succeedsConsumer crashesBefore completion isrecordedP9 returnsSame messagedelivered againRecover paymentP9Retry or query thesame provider IDResolve theresultSave charge orrequired refund12345Find the duplicate-charge boundaryFollow the successful charge before the crash. The queue can redeliver P9 even though the provider already charged it. Resolve the same payment identity and reconcile ambiguous business state. Numbered arrows correspond to the connection key below. All connections are directional.Payment P9Queue deliveryProvider chargeEffect succeedsConsumer crashesBefore completion isrecordedP9 returnsSame messagedelivered againRecover paymentP9Retry or query thesame provider IDResolve theresultSave charge orrequired refund12345

Follow the numbered arrows

  1. Payment P9 → Provider chargerequest payment P9
  2. Provider charge → Consumer crashescharge succeeds before crash
  3. Consumer crashes → P9 returnsbroker may retry
  4. P9 returns → Recover payment P9query or retry the original payment P9
  5. Recover payment P9 → Resolve the resultrecover accepted outcome
The provider charges before the worker crashes. A repeated delivery must look up or recover payment P9’s result; the broker cannot infer that result from its missing acknowledgment.
Trace the diagram in words
  1. Follow the successful charge before the crash.
  2. The queue can redeliver P9 even though the provider already charged it.
  3. Resolve the same payment identity and reconcile ambiguous business state.

DRAW. CALCULATE. EXPLAIN.

Repair the seat-purchase answer

20 minutes · guided practice

Two buyers see S7 available in cache. One worker charges payment P9, crashes before recording completion and receives the task again after reservation expiry.

  1. Show the database operation that permits one seat owner.
  2. Show the payment-record check on redelivery.
  3. Explain how to resolve the provider result and an expired seat claim.
Your self-check
Compare the worked solution
  1. Treat the map as a suggestion. Inventory checks availability and saves one winning reservation together; the other buyer receives conflict.
  2. When P9 is delivered again, read its saved result. If it is completed, reuse it. If unknown, query or retry the provider with the same supported payment identifier and retain pending recovery responsibility.
  3. Check current reservation and seat ownership before confirming the booking. Expiry may have allowed another buyer to acquire the seat.
  4. If P9 captured money without valid inventory, save and finish the chosen compensation, such as refund-required status. Do not take the later buyer’s seat or start a fresh charge to discover what happened.

The checkboxes record your own assessment. The worked solution gives you a way to check the reasoning.

RETRIEVE BEFORE YOU REVEAL

Keep the important ideas.

Say the answer aloud, then turn the card over.

CARD 01What should I do after spotting a flaw?
  1. Name the assumption that failed.
  2. Change the affected read or write.
  3. Explain its added cost.
  4. Rerun the failure example and inspect the saved result.

Keep the parts of the design that still work.

CARD 02Why does a queue not prove one payment?
  1. A provider can charge before the worker saves completion.
  2. The queue may redeliver the task.
  3. Check the saved payment result and retry/query the same provider-supported identifier.

A local processed flag cannot atomically control an unrelated provider.

CARD 03What does cached availability mean?
  1. Use the cached map to help buyers choose.
  2. Ask inventory to check availability and claim the seat together.
  3. Only that accepted claim establishes ownership.

Two buyers seeing the same green entry does not reserve it twice.

Practise this topic in the revision deck ↗

CHECK THE REASONING

Can you explain the choice?

Answer every question, then finish for an immediate score and an explanation for each answer. Aim for 80%, then revisit any gaps.

1 / 10Two buyers see cached availability for S7. What establishes exclusive ownership?
2 / 10A payment provider succeeds, then the consumer crashes before acknowledgment. What may happen next?
3 / 10P9 has an uncertain result. Which retry supports duplicate protection?
4 / 10Reservation R12 expires before a delayed payment completes. What is required?
5 / 10What does a client timeout prove?
6 / 10A candidate finds an authorization gap. Which recovery is strongest?
7 / 10Why can a healthy fleet average hide a seat-sale outage?
8 / 10The chosen database’s isolation behavior is unfamiliar. What should the candidate do?
9 / 10The old design treats a cached available seat as guaranteed purchase ownership. What should the correction revisit?
10 / 10Which statement avoids premature complexity?
0 of 10 answered

CLOSE THE LOOP

Explain it without the page.

Summarise the mechanism, one trade-off, and one failure mode. Then mark this chapter complete.