In this lesson · topic 1 of 7
Topic 1
Half of a transfer
3 min read
Two databases, one transfer
A transfer takes 50 from an account in one database and adds it to an account in another. Each database can commit its own change atomically. Nothing ties the two commits together.
Say the first commit succeeds and the machine running the transfer dies before the second. The money has left one account and arrived nowhere. Say you order them the other way. Now the money exists twice. Retrying does not fix it, because the code that crashed cannot tell which commit ran.
The goal is atomic commit across machines. Either every participant commits, or every participant aborts. No one is allowed to disagree.
The price of agreeing
Agreement needs every participant to say yes before anyone commits. That is a power law. If each participant votes no with chance 5 percent, then with two participants all vote yes 90%measured of the time. With eight, only 66%measured of the time. Each machine you add is another one that can refuse, be slow or be down.
Predict first