Showing posts with label 2PC Protocol. Show all posts
Showing posts with label 2PC Protocol. Show all posts

Tuesday, July 5, 2016

Distributed Transactions


Transactions in distributed database / Transaction manager / Transaction coordinator / Commit protocols / 2 Phase commit protocol

Transactions in Distributed Database Management System

Introduction

In centralized database system, it is mandatory to perform any transaction (ie., accessing any data items) under the satisfaction of ACID (Atomicity, Consistency, Isolation, and Durability) properties. The act of preserving the ACID properties for any transaction is mandatory in Distributed Database (distributed transaction) also. In case of distributed transactions, there are two types based on the location of accessed data. The first one, the local transactions involve read, write, or update of data in only one local database. Whereas, the global transactions involve read, write, or update of data in many such local databases.

Distributed database – Transaction system

The transaction system consists of two important components, 1. Transaction manager (which is similar to the transaction manager in centralized database. But, in distributed database we have one for every site), whose main job is to verify the ACID properties of those transactions that execute at that site, 2. Transaction Coordinator, (available for every site in distributed database) to manage and coordinate various transactions (both local and global) initiated at that site.

Transaction System Structure for Distributed Database


Each Transaction Manager is responsible for,
·         Maintaining a log for recovery purpose,
·         Participating in an appropriate concurrency-control scheme (more on this later) to coordinate the concurrent execution of the transactions executing at that site.

Every Transaction Coordinator is responsible for,
·         Starting the execution of every transaction at that site,
·         Breaking the transaction into a number of sub-transactions and distributing these sub-transactions to the appropriate sites for execution (In the diagram, the links from TC1 to TM2, TC1 to TM3, TC1 to TM4 and so on and TC1 to TMn mention the distribution of sub-transactions to the concerned transaction managers),
·         Coordinating the termination of the transaction.



Commit Protocols

As we noted earlier, satisfaction of ACID properties is very well important. At the initial stage, we need to ensure that the transaction is atomic (i.e., either completed as a whole or not). In distributed database, the transaction, say T, which is going on in multiple sites must be committed at all sites to say that the transaction T is successfully completed. If not, the transaction T must be aborted at all the sites. To implement this, we need a commit protocol. The simplest among the commit protocol is the Two-Phase Commit protocol which is widely used.



***********







Friday, June 26, 2015

How does 2PC protocol handles failures in distributed database?

How does 2PC protocol handles failures in distributed database? / Handling participating site failure / Handling coordinator site failure / Handling network partition failure / How does Two Phase Commit protocol act to handle various failures in a distributed database?


Following are the failures that are possible in a distributed database environment. Clicking on the links that are given below will take you to the posts.

 

Sunday, November 23, 2014

Two Phase Commit Protocol in Animation

Two Phase Commit protocol animated / Animation of Two Phase Commit protocol

Two Phase Commit protocol is used to ensure atomicity of transactions in Distributed database system. Using this, we can perform a consistent transactions which lead to consistent database.





Important links - Two Phase Commit protocol - in text
                                                                                 in Pictures


Developed by: Mr. Nilesh Kesharwani, and Ms. Sushmita Kumari








Saturday, August 9, 2014

Two Phase Commit protocol control messages

The list of control messages used by 2PC to control a distributed transaction / What are the control messages used by 2PC to handle transaction and recovery?


The following are the control messages used by 2 Phase Commit (2PC) protocol for handling concurrent transactions;

<Prepare T> - Sent by the Transaction Coordinator of Transaction T to all the Participating Sites where Transaction T is executed.

<Ready T> - Sent by the Transaction Managers of all the participating sites whichever is ready to commit the Transaction T.

<No T> - Used by any Transaction Manager of the participating sites which is not ready for committing the Transaction T. This message is stored in the local log file of the participating site which is not ready for commit.

<Abort T> - Sent by a Transaction Manager of participating site which is not ready for commit. Also, sent by Transaction Coordinator to all participating sites to abort the Transaction T.

<Commit T> - Sent by Transaction Coordinator of Transaction T, if TC received <ready T> messages from all the participating sites.

Commit Protocol in Distributed Database - Questions with Answers


Questions and Answers in Distributed Database Management System - Commit Protocols / Distributed Database Question and Answers on the topic Commit Protocols / Practice Exam Questions with Answers in Distributed Database / Advanced Database Systems Questions and Answers

Commit Protocols - Questions and Answers in Distributed Database Management System

Click on the questions for answers:


4
Figure 1 - Execution of Transaction T in a distributed environment
Figure 1 shows a distributed database configured on sites A, B, C, and D. All the sites are connected. Assume that a request in the form of Transaction T is reaching Site A. For this case represented in Figure 1, answer the following questions;
5.
Figure 2 - Execution of Transaction T in a distributed environment

Figure 2 shows a distributed database consists of sites A, B, C, and D. The connections between different sites are shown in dashed lines. Answer the following questions;
(a) Assume that Site A initiates transaction T, and both Site A and Site C contains data for executing transaction T. Also assume that the link between Site A and Site D is failed. What is the effect of the link failure in handling the transaction T?
(b) Assume that the transaction T which is initiated at Site A need to be executed at all the sites (Site A, B, C, and D). If the communication link between Site A and Site B is failed, how does Site B can handle the situation?

6. In 2PC protocol, the coordinator failure is considered as the major disadvantage of 2PC protocol. Why?

8. How is Persistent Messaging (an alternate way to perform transaction processing) implemented?


*************


Go to Distributed Database home





Saturday, July 19, 2014

Handling of Network Partition Failure

Handling of Network Partitions by 2PC / Two Phase Commit Protocol handling Network Partitions / How does 2PC handle Network Partition failure?




Figure - Network Partition - Single network broken into two

Handling Network Partitions

It refers to the failure of a network device that leads to the break of one network into two. For more information, visit Network Partition definitions in Wikipedia and Symantec sites.




During the execution of a transaction T, if any Network Partition happens, then there are two possibilities of execution of transaction T.

Possibility 1

The coordinator site and all the other participating sites may belong to one of the partitions. That is, no sites are disconnected from the other physically. For this case, we do not need to worry. The reason is, all the components executing transaction T are available in one partition. Hence, 2PC does not have anything to do with this failure.

Possibility 2

The coordinator site and all the other participating sites may belong to several partitions. In this case, the Network Partition affects the execution.
Now, the sites that are in a partition which is disconnected from coordinator execute 2PC for handling coordinator failure.
The sites that are in a partition along with the coordinator execute 2PC for handling site failure.

 

Featured Content

Multiple choice questions in Natural Language Processing Home

MCQ in Natural Language Processing, Quiz questions with answers in NLP, Top interview questions in NLP with answers Multiple Choice Que...

All time most popular contents