Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 ICS 214B: Transaction Processing and Distributed Data Management Lecture 12: Three-Phase Commits (3PC) Professor Chen Li.

Similar presentations


Presentation on theme: "1 ICS 214B: Transaction Processing and Distributed Data Management Lecture 12: Three-Phase Commits (3PC) Professor Chen Li."— Presentation transcript:

1 1 ICS 214B: Transaction Processing and Distributed Data Management Lecture 12: Three-Phase Commits (3PC) Professor Chen Li

2 ICS214BNotes 122 2PC is blocking Sample scenario: CoordP2 W P1P3 W P4 W

3 ICS214BNotes 123 Case I: P 1  “W”; coordinator sent commits P 1  “C” Case II: P 1  NO; P 1  A  P 2, P 3, P 4 (surviving participants) cannot safely abort or commit transaction coord P1P1 P2P2 P3P3 P4P4 w w w

4 ICS214BNotes 124 Complexity analysis Count number of messages, rounds –N participants Centralized 2PC –Ignore DONE messages –If there are no failures:  3 rounds  3N messages

5 ICS214BNotes 125 Variants of 2PC Linear Coord Hierarchical ok commit

6 ICS214BNotes 126 Distributed –Nodes broadcast all messages –Every node knows when to commit Variants of 2PC

7 ICS214BNotes 127 Exercise Compare 2PC variants in terms of –Number of rounds –Number of messages

8 ICS214BNotes 128 Cooperative Termination Protocol Bad case –Participant P recovers from failure –Has prepared record for transaction T –No commit or abort record for T –Coordinator is down Participant P is blocked until coordinator recovers

9 ICS214BNotes 129 Cooperative termination protocol But perhaps some other participant can help? Requires participants “know” each other!

10 ICS214BNotes 1210 Cooperative Termination Protocol Participant P sends a DECISION- REQUEST message to other participants Alive participants respond with COMMIT, ABORT, or UNCERTAIN If any participant replies with a decision (COMMIT or ABORT), P acts on decision –And sends decision to UNCERTAIN participants

11 ICS214BNotes 1211 Cooperative Termination Protocol When P receives a DECISION-REQUEST –If it knows decision, responds with COMMIT or ABORT –If it has not prepared transaction, responds ABORT –If it is prepared but does not know decision, responds UNCERTAIN

12 ICS214BNotes 1212 Cooperative Termination Sample scenario: CoordP1 C P2 W P3 W

13 ICS214BNotes 1213 Cooperative Termination Sample scenario: CoordP1 W P2 W P3 A

14 ICS214BNotes 1214 Cooperative Termination Sample scenario: CoordP1 W P2 W P3 W

15 ICS214BNotes 1215 Is there a non-blocking protocol? Theorem: If communications failure or total site failures (i.e., all sites are down simultaneously) are possible, then every atomic protocol may cause processes to become blocked.

16 ICS214BNotes 1216 Next… Three-phase commit (3PC) –Nonblocking if reliable network (no communications failure) and no total site failures –Handling communications failures

17 ICS214BNotes 1217 Three-Phase Commit Sample scenario: CoordP1 W P2 W P3 W

18 ICS214BNotes 1218 Coordinator Participant REQUEST-TO-PREPARE PREPARED COMMIT/ABORT DONE Uncertainty period

19 ICS214BNotes 1219 3PC Principle If ANY operational site is in the “uncertain” state, NO site (operational or failed) could have decided to commit Reminder: Assume reliable network

20 ICS214BNotes 1220 Coordinator Participant REQUEST-TO-PREPARE PREPARED COMMIT DONE PRECOMMIT ACK

21 ICS214BNotes 1221 Coordinator Participant REQUEST-TO-PREPARE NO ABORT DONE

22 ICS214BNotes 1222 Coordinator Participant Log start-3PC record (participant list) Log commit record (state C) Log prepared record (state W) Log committed record (state C) REQUEST-PREPARE PREPARED COMMIT PRECOMMIT ACK

23 ICS214BNotes 1223 Coordinator Participant REQUEST-PREPARE PREPARED COMMIT PRECOMMIT ACK 1. Timeout: Abort 2. Timeout: ignore 1. Timeout: abort 2. Timeout Termination Protocol 3. Timeout Termination Protocol

24 ICS214BNotes 1224 Process categories Three categories –Operational  Process has been up since start of 3PC –Failed  Process has halted since start of 3PC, or is recovering –Recovered  Process that failed and has completed recovery

25 ICS214BNotes 1225 Termination Protocol Start 3PC Coordinator fails Decision reached All sites learn decision Only operational processes participate in termination protocol. Recovered processes wait until decision is reached and then learn decision

26 ICS214BNotes 1226 Coordinator Participant REQUEST-PREPARE PREPARED COMMIT PRECOMMIT ACK Abortable (A) Uncertain (U) Precommitted (PC) Committed (C)

27 ICS214BNotes 1227 Termination Protocol Elect new coordinator –Use Election Protocol (coming soon…) New coordinator sends STATE- REQUEST to participants Makes decision using termination rules Communicates to participants

28 ICS214BNotes 1228 Coordinator Participant STATE-REQUEST* ABORTABLE ABORT*

29 ICS214BNotes 1229 Coordinator Participant STATE-REQUEST* COMMITTED COMMIT*

30 ICS214BNotes 1230 Coordinator Participant STATE-REQUEST* UNCERTAIN* ABORT*

31 ICS214BNotes 1231 Coordinator Participant STATE-REQUEST* PRECOMMITTED, NO COMMITTED COMMIT* PRECOMMIT* ACK*

32 ICS214BNotes 1232 Termination Protocol Sample scenario: CoordP1 W P2 W P3 W

33 ICS214BNotes 1233 Termination Protocol Sample scenario: CoordP1 W P2 W P3 PC

34 ICS214BNotes 1234 Note: 3PC unsafe with communication failures! W W W P P abort commit


Download ppt "1 ICS 214B: Transaction Processing and Distributed Data Management Lecture 12: Three-Phase Commits (3PC) Professor Chen Li."

Similar presentations


Ads by Google