HomeChallengesRepsProblemsLeaderboardTake a challenge

The order that never undoes

An order spans two services: Fulfilment puts the bundle on the line, then Wallet takes the money. When the payment fails, the customer keeps the bundle for free, because the failure never reaches the order and nothing is undone. Trace it first, then fix it.

Advanced35 min on the clock6 graded checks · 100 pointsServices That Fail PolitelyPro

AssumesWhere the transaction endsAll or nothing inside one database, where a transaction can do it for you. A saga is what you write when the steps live in two databases and it cannot.

Graded by reading your code against the checklist below.

What you build

  • Fill in Trace.cs before changing any code
  • Correlate both faults on the order id inside the failed command
  • Fail the order when the grant fails
  • When the payment fails, revoke the bundle that was already granted
  • Ignore a second OrderPlaced while the order is in progress
  • Ignore late or duplicate messages once the order has finished

Done means

The trace is right, faults correlate on the inner message, a grant failure faults the order, a payment failure revokes the bundle, and duplicates and late arrivals are ignored.

How it is graded

Published in full, before you start — every point is one of these and there is nothing else.

  1. The trace names the right states+10Undoing a step in another service
  2. Both faults correlate on the inner order id+20Undoing a step in another service
  3. A failed grant faults the order+15Undoing a step in another service
  4. A failed payment revokes the bundle+25Undoing a step in another service
  5. A second OrderPlaced is ignored mid-order+10Safe to repeat
  6. Late messages are ignored after the end+20Messages arrive twice, late, or never

What it teaches

Safe to repeatintermediate

A request that times out has not necessarily failed — you just did not hear back — so the client retries, and unless the write recognises that it has already happened the customer is charged twice.

The rest of Services That Fail Politely