Try
↑ ↓ move↵ openesc close

Interview prep / Two-phase commit

Mid · Two-phase commit · System design interview question

The coordinator crashes after every participant voted yes. What state are the participants in, and what can they do?

Sketch your own answer first, then compare it with the one below.

A strong answer

They are in doubt. Each one promised to commit and is holding locks, but none knows the decision. If it commits, another participant may have been told to abort. If it aborts, the coordinator may have decided commit.

A participant cannot choose on its own. It must wait for the coordinator to recover and read its log, or learn the decision from a peer that heard it. Until then, the locks stay held and other transactions that need those rows wait behind them.

This is why two-phase commit is called blocking. A good answer names the lock holding, and says that a longer outage means a longer block.

Sources

Learn it by running it

The two-phase commit lesson explains the mechanism behind this question, and its lab lets you change the parameters and watch the effect.

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