System Design Patterns: From Fundamentals to Real Systems
0% completed
Two-Phase Commit
1. The Incident
The store launched gift cards, and customers can transfer balance to each other. Customer A (shard 2) sends $50 to customer B (shard 5): and the sharding lesson's warning bill has arrived: this is one logical operation that must change two databases, and no single transaction covers both.
The first implementation does the obvious: subtract 50 on shard 2, then add 50 on shard 5. Two writes, one after the other. It works thousands of times. Then, at 2:37 AM, the app server crashes in the gap: after the subtract committed, before the add was sent
.....
.....
.....
Like the course? Get enrolled and start learning!