Question

I understand that both algorithms are very different, but what I don't understand is whether they achieve the same thing in the end. 2PC is for atomic commits and 2PL is for serializable isolation. But don't they both achieve the two things? don't these goals imply each other in the end?

Was it helpful?

Solution

These are two different things that have two different goals.

The two-phase locking protocol is designed to guarantee serializability for transactions that access concurrently a single, centralized database, using a locking mechanism. So its goal is to maintain the consistency of a centralized database, avoiding “bad” interferences among concurrent, different, transactions that operate on the same data.

Two-phase commit protocol, instead, concerns the execution of distributed transactions is a distributed database, and guarantee that a single distributed transaction, seen as “set of processes in a network system”, coordinates the work of those processes even in case of temporary system failures (for instance, in case of network failure). So the protocol has the objective of avoiding situations in which a certain transaction commit its operation is a node (that is in a part of the distributed database), but aborts in another node (that is in another part of the same distributed database).

Of course you can see both protocols as having the final objective is to maintain the “consistency” of the database, centralized in a case, distributed in the other. But this is really a generic point of view.

Licensed under: CC-BY-SA with attribution
Not affiliated with cs.stackexchange
scroll top