Try
↑ ↓ move↵ openesc close

Interview prep / Two-phase commit

Mid · Two-phase commit · System design interview question

Which timeouts are safe in two-phase commit, and which are not?

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

A strong answer

Before a participant votes, it can abort alone after a timeout. No one can have committed without its yes, so this is safe.

The coordinator can also abort when a vote does not arrive. Nobody has been told to commit yet.

After a participant votes yes, a timeout is not a license to abort. The coordinator may have decided commit and told someone else. An abort by this participant would split the outcome, which is the one thing the protocol exists to prevent. The safe moves are to keep waiting, ask the coordinator, or ask peers.

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