System Design Patterns: From Fundamentals to Real Systems
Vote

0% completed

​

Two-Phase Commit

Maya Ortiz sends $50 of her gift-card balance to her friend Daniel Okafor. The store keeps each customer's gift-card balance in that customer's row, and customers are spread across database shards by customer ID. Maya's row is on shard 1 and Daniel's row is on shard 3, so the transfer service runs one transaction on each shard:

-- On shard 1 BEGIN; UPDATE gift_cards SET balance = balance - 50 WHERE customer_id = 'maya'; -- $120 becomes $70 COMMIT; -- The transfer service crashes here. -- On shard 3 (never runs) BEGIN;

.....

.....

.....

Like the course? Get enrolled and start learning!

Reading Progress

0%


Vote for new content