Thursday, December 31, 2020

Quiz questions and answers in distributed database MCQ 08

Distributed database quiz questions with answers, MCQ in distributed database, solved exam questions in distributed database, distributed transaction processing, two phase commit protocol

Multiple Choice Questions with Answers in Distributed Database

Let us suppose that there are a transaction coordinator Tc and two participants P1 and P2. They are working on a transaction T1.

[Refer here to understand more and to answer – 2PC protocol]

 

1. Which of the following will happen after the following sequence of events is completed as per Two Phase Commit (2PC) protocol?

TC sends <Prepare T1> to P1 and P2.

P1 sends <Ready T1> to TC.

P2 sends <Ready T1> to TC.

a) TC sends <Commit T1> to P1.

b) TC sends <Commit T1> to P2.

c) TC sends <Abort T1> to P1.

d) TC sends <Abort T1> to P2.

Answer: (a) TC sends <Commit T1> to P1 and (b) TC sends <Commit T1> to P2

It is given that the transaction coordinator sent a prepare message to all the participating sites and in-turn the participants responded with ready message.

If all the participating sites are responded with ready message (these responses only known to coordinator at this moment), then the coordinator sends the commit message to all the participants.

 

2. Which of the following will happen after the following sequence of events is completed as per 2PC?

TC sends <Prepare T1> to P1 and P2.

P1 sends <Ready T1> to TC.

P2 sends <Ready T1> to TC.

P2 crashed after sending <Ready T1> to TC.

P2 recovered immediately after crash.

a) TC sends <Commit T1> to P1 and P2

b) TC sends <Abort T1> to P1 and P2.

c) TC sends <Commit T1> only to participant P1.

d) TC sends <Abort T1> only to participant P2.

Answer: (a) TC sends <Commit T1> to P1 and P2

It is given that the transaction coordinator sent a prepare message to all the participating sites and in-turn all the participants responded with ready message. After that P2 crashed and recovered. We can understand that the crash and recovery happened before the coordinator responds.

Whether the participating sites crashed or not, the coordinator will respond based on the messages it received from the participating sites. Hence, in this case, Tc will send the commit message to all the participants.

 

3. After the event “TC sends <Prepare T1> to P1 and P2, P1 decides to commit transaction T1. Which of the following is true about P1 with respect to 2PC protocol?

a) P1 sends <Ready T1> to TC and then writes <Ready T1> into its local log

b) P1 writes <Ready T1> into its local log and then sends <Ready T1> to TC

c) P1 sends <Ready T1> to TC and then writes <Commit T1> into its local log

d) P1 writes <Commit T1> into its local log and then sends <Ready T1> to TC

Answer: (b) P1 writes <Ready T1> into its local log and then sends <Ready T1> to TC

In 2PC, if a participating site decided to commit or abort, it has to first register the decision into local log file, flush the log file into disk and then reply with the appropriate message to the coordinator site.

 

4. Which of the following will happen if P2 is not ready to commit T1 after the following events?

TC sends <Prepare T1> to P1 and P2.

P1 sends <Ready T1> to TC.

a) P2 sends <Commit T1> to Tc.

b) P2 writes <Abort T1> to its local log and sends <Abort T1> to Tc.

c) P2 writes <Abort T1> to its local log and sends <Abort T1> to Tc and P1.

d) P2 writes <No T1> to its local log and sends <Abort T1> to TC.

Answer: (d) P2 writes <No T1> to its local log and sends <Abort T1> to TC

According to 2PC, if a participating site has decided not to commit, it has to write <No T> message into its log and send <Abort T> to the transaction coordinators.

 

5. Which of the following will happen after the following sequence of events is completed as per Two Phase Commit (2PC) protocol?

TC sends <Prepare T1> to P1 and P2.

P1 sends <Ready T1> to TC.

P2 sends <Abort T1> to TC.

a) TC sends <Commit T1> to P1 and P2

b) TC sends <Abort T1> to P1 and P2.

c) TC sends <Commit T1>, only to participant P1.

d) TC sends <Abort T1>, only to participant P2.

Answer: (b) TC sends <Abort T1> to P1 and P2

It is given that the transaction coordinator sent a prepare message to all the participating sites. One of the sites is not ready to commit the transaction. In this case, the coordinator has to abort the transaction and inform all the participating sites to abort T1.

 

**********

Related links:



Distributed database multiple choice questions with answers

important quiz questions in DDB

important GATE exam questions in distributed database

University exam questions in distributed database

messages handled by 2 phase commit 2PC protocol

prepare, commit, abort and no messages in two phase commit protocol

No comments:

Post a Comment

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