Opening Scenario
You're building an e-commerce checkout flow. When a user places an order, your application needs to:
- Deduct items from inventory
- Create an order record
- Charge the user's payment method
- Send a confirmation email trigger
Your code runs these as four separate database writes. On a quiet Tuesday, everything works. But on Black Friday, with hundreds of concurrent checkouts, you start seeing inventory counts go negative and orders created without matching payment records. Your logs show no errors — the writes all succeeded individually.
What went wrong, and how do you fix it?
Question Progression
Q1: Why did individual successful writes still produce corrupt state?
Question: Each of your four writes returned success. The database accepted every row. So why is your data wrong?
Reasoning: Think about what "success" means for a single write. The database confirmed that that write completed. But it said nothing about…
In the full tutorial
- Closing: When to Reach for This