Distributed transactions Flat Atomicity distributed transactions coordinator twophase
Σε αυτό το μάθημα • Distributed transactions – Flat • Atomicity σε distributed transactions – Ύπαρξη coordinator – Πρωτόκολλο two-phase commit • Concurrency control σε distributed transactions – Τοπικά σε κάθε server – Καθολικά στο σύνολο των servers • Distributed Deadlocks 30/10/2020
Distributed Transactions • Transactions που προσπελάζουν αντικείμενα διαχειριζόμενα από πολλούς servers M X T 11 X Client T Y T T 1 N T 12 T T 21 T 2 Client Y (a) Flat transaction 30/10/2020 Z P T 22 (b) Nested transactions
Σχηματικά join Coordinat or join T Participant X A Participant join Y B Participant C Z D Coordinator & Participants 30/10/2020
Παράδειγμα join open. Transaction close. Transaction. participant A a. withdraw(4); join Branch. X T Client T = open. Transaction a. withdraw(4); c. deposit(4); b. withdraw(3); d. deposit(3); close. Transaction participant b. withdraw(T, 3); B join Note: the coordinator is in one of the servers, e. g. Branch. X 30/10/2020 b. withdraw(3); Branch. Y participant C c. deposit(4); D d. deposit(3); Branch. Z
Transaction states 30/10/2020
Λειτουργίες του 2 PC • • • can. Commit? (trans)-> Yes / No do. Commit(trans) do. Abort(trans) have. Committed(trans, participant) get. Decision(trans) -> Yes / No Participant interface Coordinator interface – Call from participant to coordinator to ask for the decision on a transaction after it has voted Yes but has still had no reply after some delay. Used to recover from server crash or delayed messages. 30/10/2020
Το πρωτόκολλο • 1η φάση: Voting phase t? n ca i mm Co ? mmit o C n a c can. Co mmit? ca n. C 30/10/2020 om mi t?
Το πρωτόκολλο • 2η φάση: commit phase: ack από όλους ted C ve i mm o ha ed ommit have. C ommite ha ve Co mm ite 30/10/2020 d d
Παράδειγμα Τ Write(A) Read(B) 30/10/2020 U at X at Y Lock A Write(B) at Y lock B Read(A) at X Wait for T Wait for U
Commitment deadlock Τ read(A) U at X write(A) read(B) write(B) read(B) at Y write(B) at Y read(A) at X write(A) • Ο server X κάνει validate πρώτα το Τ ενώ ο server Y το U • Μόνο ένα transaction μπορεί να εκτελεί validation και update κάθε φορά • Κανένας server δεν μπορεί να κάνει validate το δεύτερο transaction αν δεν τελειώσει το πρώτο 30/10/2020
Παράδειγμα deadlock Held by Waits for A U T Waits for B Held by Υπάρχει deadlock αν και μόνο αν υπάρχει κύκλος στον γράφο wait-for 30/10/2020
Κεντρικός εντοπισμός waits_for held_by 30/10/2020 waits_for held_by
Παράδειγμα phantom deadlock 30/10/2020
Παράδειγμα phantom deadlock 30/10/2020
Ανακεφαλαίωση • Distributed transactions – Flat • Atomicity σε distributed transactions – 1 -phase commit – 2 -phase commit – 3 -phase commit • Concurrency control σε distributed transactions – Τοπικά σε κάθε server – Καθολικά στο σύνολο των servers • Distributed Deadlocks – Detection – Prevention 30/10/2020
- Slides: 58