Showing posts with label Distributed Database. Show all posts
Showing posts with label Distributed Database. Show all posts

Tuesday, July 5, 2016

Two Phase Commit Protocol

Two Phase Commit Protocol, Explain 2PC protocol, How does 2 Phase Commit protocol work?, Two phase protocol in handling distributed transactions, 2PC and distributed concurrency control


Two Phase Commit protocol in Distributed Database

Two Phase Commit (2PC) Protocol
Consider a transaction T initiated at site Sitei. And, at that site the transaction coordinator is TCi. When the transaction started, TCi distributes the sub-transactions to the sites where the data needed for those sub-transactions available. When T completed its execution at all the sites at which T has executed, the transaction managers (TMs) of those sites inform TCi about the completion. Then TCi starts the 2PC protocol. It works as follows;

Set of messages used for communication in 2PC protocol are,


MESSAGE
DESCRIPTION
<prepare T>
send by the coordinator to all the participating sites for preparing for commit. It is always sent by the coordinator whenever a transaction is ready.
<ready T>
send by the transaction manager of the participating site as reply for <prepare T> message, if the sending site is ready for commit the ongoing transaction.
<abort T>
send by the transaction manager of the participating site and later by the coordinator to all the participating site, if any one or more of the participating sites are not ready to commit.
<no T>
it is the log written to the log file of the local system by the transaction manager of the participating site, if it is not ready to commit (which also send <abort T> to the coordinator)
<commit T>
send by the coordinator if all the sites are ready for a commit.

Phase 1: Transaction Coordinator TCi inserts a <preapare T> message into the log file, and forces the log into stable storage (for example, hard disk) for the recovery purpose. Then it sends <prepare T> message to all the sites where the transaction T is being executed. On receiving such message, the TM of the participating site must decide to commit or not based on its status. If the TM of the receiving site decided not to commit for some reasons (failure of transaction, message failure, locking etc.), it write <no T> to its log, and sends <abort T> message to the coordinator TCi. If the TM is read to commit, then it sends <ready T> message to the coordinator TCi. In both the cases, (i.e., no T, or ready T), the messages first written into the stable storage of that site where it is decided and send back to the coordinator.

Phase 2: when TCi receives reply messages for <prepare T> message, or after the pre-specified time interval, the TCi can decide the fate of the transaction. Transaction T can be committed if it received <ready T> message from all the participating sites of the transaction T. Then TCi write a message <commit T> into its stable storage and send <commit T> to all the participating sites for them to commit the transaction. If any one of the reply is <abort T> or no reply on the specified time interval, the transaction must be aborted. In this case, a <abort T> message must be written into stable storage and sent to all the participating sites to abort as well.

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




How does 2PC protocol work?

What is two phase commit protocol in distributed transactions

Explain 2PC protocol

What are the two phases in 2PC protocl

How distributed transactions are managed using two phase commit protocol?






Wednesday, February 24, 2016

Fragmentation in Distributed Database - Quiz

Database System Architectures - Quiz


1. What are the advantages of Replication of data in Distributed database?
    Avaliability, Parallelism, Increased data transfer
    Availability, Parallelism, Reduced data transfer
    Availability, Increased parallelism, Cost of updates
    All of the above

2. A fragmentation technique wherein every tuple of a table is assigned to one or more fragments as a result of fragmentation is called ________________ .
    Vertical Fragmentation
    Horizontal Fragmentation
    Hybrid Fragmentation
    None of the above

Assume a relation EMP as given below:
                EMP(EmpNo, EName, Job, Sal, Department)
Furthermore, assume that there are two applications which are accessing the above mentioned table. One application typically retrieves information about employees who earn more than Rs5.000, the other application typically manages information about 'clerks' (job). Also, assume that there are employees with other designations and different salaries stored in EMP. With this information, answer the questions 3 to 6.

3. Which of the following are the simple predicates which can be directly extracted from the given applications?
    {Job = clerk, Salary>5000}
    {Job = clerk, Salary<5000}
    {Job = Manager, Salary>5000}
    {Job = Manager, Salary<5000}

4. How many valid minterm predicates we can derive for the above said problem?
    4
    5
    3
    2

5. Assume that the departments are 'Finance', 'Production', and 'Design'. If there is one more application which accesses the informatoin frequently based on the 'Finance' department, what would be the number of valid minterm fragments?
    5
    6
    7
    8

6. If by mistake, I miss one of the valid minterm fragments. What would be the effect of that in fragmentation?
    Causes skew
    Reconstruction of EMP will be unsuccessful
    Slows down the database access
    None

7. Which of the following failures are unique to distributed database systems?
    Failure of a site
    Loss of messages
    Network Partition
    All the above

8. For the given set of simple predicates Pr, how many min-term predicates we can derive (including invalid ones). Pr = {Branch = “Vellore”, Branch = “Chennai”, Salary <=20000, Salary > 20000} Assumptions: Consider there are five different branches.
    4
    8
    16
    32

9. In a distributed database application, if we have very many number of read only queries than update queries then ______________ allocation technique is advantageous.
    Hybrid Fragmentation
    Horizontal Fragmentation
    Replication
    Vertical Fragmentation

10. Which of the following would be the advantage of Database Fragmentation?
    Most of the operations are local to any sites
    Reduced Network Traffic
    Parallel processing
    All the above

Score =

Correct answers:

Go to Distributed Database Quizzes - Home page

Friday, May 15, 2015

Date's Tweleve Rules for Distributed Database Systems - Database (DBMS) Independence

Date's Tweleve Rules for Distributed Database Systems - Database [DBMS] Independence


DBMS independence

The system must support any vendor's database product. The DBMS instances at different sites all support the same interface - they do not necessarily all have to be copies of the same DBMS software. The ideal distributed system should be heterogeneous and should provide DBMS independence.
For example, if Ingres and Oracle both supported the official SQL standard, the Ingres site and the Oracle site might be able to talk to each other in a distributed database system. Pictorial representation of the same is given below.


Fig 1 - Distributed database with database independence (source: Prof. Sin Min Lee ppt from CJ Date book)








Sunday, April 19, 2015

Date's Tweleve Rules for Distributed Database Systems - Network Independence

Date's Tweleve Rules for Distributed Database Systems - Network Independence


The system should not depend on particular network implementations and protocols.

Network Independence rule can be defined in different way as follows;


  • Desirable to be able to support a variety of disparate communication networks also.
  • Network independence: The DDB and its associated DDBMS should be capable of being implemented on any suitable network platform. 

    Note:  At present, this goal means that the DDBMS should be able to run on Windows NT, on Windows 2000, on any variant of Unix, and on Novell Networks. 
  • A distributed database system should be designed to run regardless of the communication protocols and network topology used to interconnect various system nodes.





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

data recovery