ArticleslgStudy

science

Three-phase commit protocol

Three-phase commit protocol is a science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Three-phase commit protocol rather than just read about it. In short: In computer networking and distributed databases, the three-phase commit protocol (3PC) is a distributed algorithm that ensures all nodes in a system agree to commit or abort a transaction. It improves upon the two-phase commit protocol (2PC) by eliminating the possibility of indefinite blocking caused by a specific type of failure during the commit phase.

Key takeaways

  • Three-phase commit protocol belongs to science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Three-phase commit protocol to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Three-phase commit protocol from memory before moving on to harder problems.

Reference excerpt

In computer networking and distributed databases, the three-phase commit protocol (3PC) is a distributed algorithm that ensures all nodes in a system agree to commit or abort a transaction. It improves upon the two-phase commit protocol (2PC) by eliminating the possibility of indefinite blocking caused by a specific type of failure during the commit phase.

Motivation A two-phase commit protocol cannot dependably recover from a failure of both the coordinator and a cohort member during the commit phase. If only the coordinator had failed, and no cohort members had received a commit message, it could safely be inferred that no commit had happened. If, however, both the coordinator and a cohort member failed, it is possible that the failed cohort member was the first to be notified, and had actually done the commit. Even if a new coordinator is selected, it cannot confidently proceed with the operation until it has received an agreement from all cohort members, and hence must block until all cohort members respond. The three-phase commit protocol eliminates this problem by introducing the Prepared to commit state. If the coordinator fails before sending preCommit messages, the cohort will unanimously agree that the operation was aborted. The coordinator will not send out a doCommit message until all cohort members have ACKed that they are prepared to commit. This eliminates the possibility that any cohort member actually completed the transaction before all cohort members were aware of the decision to do so (an ambiguity that necessitated indefinite blocking in the two-phase commit protocol).

Solution The pre-commit phase introduced above helps the system to recover when a participant or both the coordinator and a participant failed during the commit phase. When the recovery coordinator takes over after the coordinator failed during a commit phase of two-phase commit, the new pre-commit comes handy as follows: On querying participants, if it learns that some nodes are in commit phase then it assumes that the previous coordinator before crashing has made the decision to commit. Hence it can shepherd the protocol to commit. Similarly, if a participant says that it had not received a PrepareToCommit message, then the new coordinator can assume that the previous coordinator failed even before it completed the PrepareToCommit phase. Hence it can safely assume that no participant has committed the changes, and hence safely abort the transaction.

Extensions Using Skeen's original three-phase commit protocol, it is possible that a quorum becomes connected without being able to make progress (this is not a deadlock situation; the system will still progress if the network partitioning is resolved). Keidar and Dolev's E3PC refines Skeen's three-phase commit protocol and solves this problem in a way which always allows a quorum to make progress.

Disadvantages Three-phase commit assumes a network with bounded delay and nodes with bounded response times; in most practical systems with unbounded network delay and process pauses, it cannot guarantee atomicity. The other drawback of the protocol is it requires at least three round trips to complete, needing a minimum of three round trip times (RTTs). This is potentially a long latency to complete each transaction.

See also Paxos algorithm

References

Worked examples

Example 1 — a first encounter with Three-phase commit protocol

Start with the simplest possible case. Write down what Three-phase commit protocol claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Three-phase commit protocol before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Three-phase commit protocol ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Three-phase commit protocol

In research
Three-phase commit protocol appears in science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Three-phase commit protocol in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Three-phase commit protocol is common in secondary-school and first-year university syllabi. It links to neighbouring topics Transaction processing, so understanding it makes those chapters shorter.
In everyday life
Look for Three-phase commit protocol outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Three-phase commit protocol” →

How to study Three-phase commit protocol in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Three-phase commit protocol means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Three-phase commit protocol out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Three-phase commit protocol in simple terms?

In computer networking and distributed databases, the three-phase commit protocol (3PC) is a distributed algorithm that ensures all nodes in a system agree to commit or abort a transaction. It improves upon the two-phase commit protocol (2PC) by eliminating the possibility of indefinite blocking ca…

Why does Three-phase commit protocol matter?

Because it connects several science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Three-phase commit protocol?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Three-phase commit protocol.

Tags

  • Transaction processing

Keep exploring