Académique Documents
Professionnel Documents
Culture Documents
Distributed transactions
M
X
T11
X
Client T1 N
T T 12
Y
T
T
T
21
T2
Client
Y
P
Z
T
22
Instructors Guide for Coulouris, Dollimore, Kindberg and Blair, Distributed Systems: Concepts and Design Edn. 5
Pearson Education 2012
Figure 17.2
Nested banking transaction
X
Client T A a.withdraw(10)
1
T
T = openTransaction Y
openSubTransaction T B b.withdraw(20)
2
a.withdraw(10);
openSubTransaction
b.withdraw(20); Z
openSubTransaction
c.deposit(10); T
3 C c.deposit(10)
openSubTransaction
d.deposit(20); T D d.deposit(20)
4
closeTransaction
Instructors Guide for Coulouris, Dollimore, Kindberg and Blair, Distributed Systems: Concepts and Design Edn. 5
Pearson Education 2012
Figure 17.3
A distributed banking transaction
T = openTransaction
join BranchY
a.withdraw(4);
c.deposit(4); participant
b.withdraw(3);
d.deposit(3); C c.deposit(4);
closeTransaction
D d.deposit(3);
Note: the coordinator is in one of the servers, e.g. BranchX
BranchZ
Instructors Guide for Coulouris, Dollimore, Kindberg and Blair, Distributed Systems: Concepts and Design Edn. 5
Pearson Education 2012
Figure 17.4
Operations for two-phase commit protocol
canCommit?(trans)-> Yes / No
Call from coordinator to participant to ask whether it can commit a transaction.
Participant replies with its vote.
doCommit(trans)
Call from coordinator to participant to tell participant to commit its part of a
transaction.
doAbort(trans)
Call from coordinator to participant to tell participant to abort its part of a
transaction.
haveCommitted(trans, participant)
Call from participant to coordinator to confirm that it has committed the
transaction.
getDecision(trans) -> Yes / No
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.
Instructors Guide for Coulouris, Dollimore, Kindberg and Blair, Distributed Systems: Concepts and Design Edn. 5
Pearson Education 2012
Figure 17.5
The two-phase commit protocol
Instructors Guide for Coulouris, Dollimore, Kindberg and Blair, Distributed Systems: Concepts and Design Edn. 5
Pearson Education 2012
Figure 17.6
Communication in two-phase commit protocol
Coordinator Participant
Instructors Guide for Coulouris, Dollimore, Kindberg and Blair, Distributed Systems: Concepts and Design Edn. 5
Pearson Education 2012
Figure 17.7
Operations in coordinator for nested transactions
Instructors Guide for Coulouris, Dollimore, Kindberg and Blair, Distributed Systems: Concepts and Design Edn. 5
Pearson Education 2012
Figure 17.8
Transaction T decides whether to commit
T abort (at M)
11
T1 provisional commit (at X)
T aborted (at Y)
2
T provisional commit (at P)
22
Instructors Guide for Coulouris, Dollimore, Kindberg and Blair, Distributed Systems: Concepts and Design Edn. 5
Pearson Education 2012
Figure 17.9
Information held by coordinators of nested transactions
Instructors Guide for Coulouris, Dollimore, Kindberg and Blair, Distributed Systems: Concepts and Design Edn. 5
Pearson Education 2012
Figure 17.10
canCommit? for hierarchic two-phase commit protocol
Instructors Guide for Coulouris, Dollimore, Kindberg and Blair, Distributed Systems: Concepts and Design Edn. 5
Pearson Education 2012
Figure 17.11
canCommit? for flat two-phase commit protoco
Instructors Guide for Coulouris, Dollimore, Kindberg and Blair, Distributed Systems: Concepts and Design Edn. 5
Pearson Education 2012
Figure 17.12
Interleavings of transactions U, V and W
U V W
d.deposit(10) lock D
b.deposit(10) lock B
a.deposit(20) lock A at Y
at X
c.deposit(30) lock C
b.withdraw(30) wait at Y at Z
c.withdraw(20) wait at Z
a.withdraw(20) wait at X
Instructors Guide for Coulouris, Dollimore, Kindberg and Blair, Distributed Systems: Concepts and Design Edn. 5
Pearson Education 2012
Figure 17.13
Distributed deadlock
(a) (b)
W
W
Held by Waits for
C D A
Z X V
Held
Waits Held by by
for U
V U
B Waits for
Held
by
Y
Instructors Guide for Coulouris, Dollimore, Kindberg and Blair, Distributed Systems: Concepts and Design Edn. 5
Pearson Education 2012
Figure 17.14
Local and global wait-for graphs
T
T U V T
U V
X Y
Instructors Guide for Coulouris, Dollimore, Kindberg and Blair, Distributed Systems: Concepts and Design Edn. 5
Pearson Education 2012
Figure 17.15
Probes transmitted to detect deadlock
W
W U V W Held by Waits for
Deadlock
detected C
A
Z
Initiation X
W U V
Waits
for W U
V
U
Instructors Guide for Coulouris, Dollimore, Kindberg and Blair, Distributed Systems: Concepts and Design Edn. 5
Pearson Education 2012
Figure 17.16
Two probes initiated
(a) initial situation (b) detection initiated at object (c) detection initiated at object
requested by T requested by W
T
Waits for T Waits for T T U
W V T
V U W V T U
V U V
T U W U
T U W V
W Waits
for W V
Waits
W W for
Instructors Guide for Coulouris, Dollimore, Kindberg and Blair, Distributed Systems: Concepts and Design Edn. 5
Pearson Education 2012
Figure 17.17
Probes travel downhill
.
.
(a) V stores probe when U starts waiting (b) Probe is forwarded when V starts waiting
W
W U V probe
U Waits V W queue
for C
U V U
V Waits for
V Waits for
probe U V B
queue U V B
Instructors Guide for Coulouris, Dollimore, Kindberg and Blair, Distributed Systems: Concepts and Design Edn. 5
Pearson Education 2012
Figure 17.18
Types of entry in a recovery file
Instructors Guide for Coulouris, Dollimore, Kindberg and Blair, Distributed Systems: Concepts and Design Edn. 5
Pearson Education 2012
Figure 17.19
Log for banking service
P0 P1 P2 P3 P4 P5 P6 P7
Object:A Object:B Object:C Object:A Object:B Trans: T Trans: T Object: C Object: B Trans: U
100 200 300 80 220 prepared committed 278 242 prepared
<A, P1 > <C, P5 >
<B, P2 > <B, P6 >
P0 P3 P4
Checkpoint
End
of log
Instructors Guide for Coulouris, Dollimore, Kindberg and Blair, Distributed Systems: Concepts and Design Edn. 5
Pearson Education 2012
Figure 17.20
Shadow versions
P0 P0' P0" P1 P2 P3 P4
Version store 100 200 300 80 220 278 242
Checkpoint
Instructors Guide for Coulouris, Dollimore, Kindberg and Blair, Distributed Systems: Concepts and Design Edn. 5
Pearson Education 2012
Figure 17.21
Log with entries relating to two-phase commit protocol
Instructors Guide for Coulouris, Dollimore, Kindberg and Blair, Distributed Systems: Concepts and Design Edn. 5
Pearson Education 2012
Figure 17.22
Recovery of the two-phase commit protocol
top of stack
T11
T A1 A11 A11 A12 A12 A2 A2
1
T T12 A1 A11 A12
T2
T1 T11 T12 T2
Instructors Guide for Coulouris, Dollimore, Kindberg and Blair, Distributed Systems: Concepts and Design Edn. 5
Pearson Education 2012