Give full details of the three-phase commit protocol in a distributed environment. Outline the algorithms for both coordinator and participants.

Algorithm (a) 3PC coordinator algorithm
Algorithm (b) 3PC participants algorithm


```
Algorithm (a) 3PC coordinator algorithm
begin

STEP C1 VOTE INSTRUCTION
write ‘begin global commit’ message to log
send ‘vote’ message to all participants
do until votes received from all participants
wait
on timeout go to STEP C2b
enddo
STEP C2a PRE-COMMIT
if all votes are ‘commit’
then begin
write ‘pre-commit’ message to log
send ‘pre-commit’ message to all participants
end
STEP C2b GLOBAL ABORT
at least one participant has voted abort or coordinator has timed out
else begin
write ‘global abort’ record to log
send ‘global abort’ to all participants
go to STEP 4
end
endif
STEP C3 GLOBAL COMMIT
do until all (pre-commit) acknowledgements received
wait
end-do
write ‘global commit’ record to log
send ‘global commit’ to all participants
end
STEP C4 TERMINATION
do until acknowledgement received from all participants
wait
enddo
write ‘end global transaction record’ to log
finish
end

Algorithm (b) 3PC participants algorithm
begin

STEP P0 WAIT FOR VOTE INSTRUCTION
do until ‘vote’ instruction received from coordinator
wait
enddo
STEP P1 VOTE
if participant is prepared to commit
then send ‘commit’ message to coordinator
else send ‘abort’ message to coordinator and go to STEP P2b
do until global vote received from coordinator
wait
enddo
STEP P2a PRE-COMMIT
if global instruction = ‘pre-commit’
then go to STEP P3 (and wait for global commit)
end-if
STEP P2b ABORT
at least one participant has voted abort
perform local abort processing
go to STEP P4
STEP P3 COMMIT
do until ‘global commit’ received from coordinator
wait
end-do
perform local commit processing
STEP P4 TERMINATION
send acknowledgement to coordinator
finish
end
```

Computer Science & Information Technology

You might also like to view...

What are the two key distance-limiting parameters in fiber-optic transmissions?

What will be an ideal response?

Computer Science & Information Technology

What tags are required for an HTML page?

a. html, head b. html, head, body, foot c. html, head, body d. no tags are required

Computer Science & Information Technology

A(n) ____ local area network is a network in which devices use high-frequency radio waves to communicate with a base station, which is connected to the Internet.

A. ?wired B. ?ethereal C. ?wireless D. ?cellular

Computer Science & Information Technology

_____ are symmetric keys to encrypt and decrypt information exchanged during the session and to verify its integrity.

A. Encrypted signatures B. Session keys C. Digital certificates D. Digital digests

Computer Science & Information Technology