Two-phase commit is simple in theory but difficult to perform in practise.

In the first phase (voting), the coordinator sends the update to all the participants. Each participant processes the update and votes whether to commit or abort. When voting to commit, the participants store the update onto a temporary area (the write-ahead log). Until the second phase completes, the update is considered temporary.

In the second phase (decision), the coordinator decides the outcome and informs every participant about it. If all participants voted to commit, then the update is taken from the temporary area and made permanent.

2PC is prone to blocking, since a single node failure (participant or coordinator) blocks progress until the node has recovered.

2PC is a CA (from CAP Theorem) - it is not partition tolerant. The failure model that 2PC addresses does not include network partitions; the prescribed way to recover from a node failure is to wait until the network partition heals.

The 2 phase commit protocol

Apache Ignite Transaction Architecture

https://redixhumayun.github.io/databases/2023/09/16/2PC.html


🌱 Back to Garden