Try
↑ ↓ move↵ openesc close
In this lesson · topic 1 of 7
  1. 1. Half of a transfer
  2. 2. Prepare, then commit
  3. 3. Crash a coordinator and count the locks
  4. 4. The coordinator that does not come back
  5. 5. Which timeout is safe
  6. 6. Three phases, and why teams skip them
  7. 7. Votes, blocking and timeouts

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

A transfer commits on database A, then the process crashes before it contacts database B. What is the state of the money?

Your progress is saved in this browser. Sign in to keep it on every device. Privacy · Terms