














Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!















Don’t use locks, detect inconsistencies at individual operations (and abort), rather than at commit point.
Each transaction is assigned a unique timestamp value when it starts (@ openTransaction()). The timestamp defines its position in the time sequence of transactions.
Transaction T { t = openTransaction(); x.write(t,2); closeTransaction(t); }
Assign timestamp
Rules Tc Ti
Each read/write operation of a transaction is checked to see whether it conforms to the following rules.
The transaction that was done by some previous operation whose timestamp indicates that it should be later than Tc
Tc=current Ti > Tc means Ti is later than Tc
Tc must not write an object that has been read by any Ti where Ti > Tc; this requires Tc >= the max. read TS of object.
Tc must not write an object that has been written by any Ti where Ti > Tc; this requires that Tc > write TS of committed object.
Tc must not read an object that has been written by any Ti where Ti > Tc; this requires that Tc > the write TS of committed obj.
Read Operations and Timestamps
(write-TS’s only shown)
(b) T 3 read
Time
read proceeds
Selected
T 2
Time
read proceeds (read T2’s version) Selected
T 2 T 4
Time
read waits
Selected
T 1 T 2
Key:
Tentative
Committed
Ti
Ti
object produced by transaction Ti (write timestampTi) T 1 < T 2 < T 3 < T 4
(a) T 3 read
(c) T 3 read (d) T^3 read
T3 > T2 & T2 committed, hence T3 read proceeds
T3 > T2 & T2 committed, hence T3 read proceeds
T3 > T2 & since T2 is tentative, T Must wait until T2 becomes committed or abort
T3 < T4 (violation of rule 3)
if ( Tc ≥ maximum read TS on D && Tc > write TS on committed version of D )
then perform write operation on tentative version of D with write TS Tc
else /* write is too late */
Abort transaction Tc
Rules 1 & 2:
Distributed Transactions
a transaction (flat or nested) that invokes
operations in several servers.
T
A
Y
Z
B
C
D
T
T
T
T
T
T
T
A
B
C
D
F
H
K
Flat Distributed Transaction Nested Distributed Transaction
X
..
BranchZ
BranchX
participant
participant
C D
Client
BranchY
B
A
join participant
join
join
T
a.withdraw(4);
c.deposit(4);
b.withdraw(3);
d.deposit(3);
openTransaction
b.withdraw(T, 3);
closeTransaction
T = openTransaction a.withdraw(4); c.deposit(4); b.withdraw(3); d.deposit(3); closeTransaction
Note: the coordinator is in one of the servers, e.g. BranchX
Atomicity principle requires that either all
the distributed operations of a transaction
complete or all abort.
At some stage, client executes
closeTransaction(). Now, atomicity requires
that either all participants and the
coordinator commit or all abort.
What problem statement is this?
I. Atomic Commit Problem
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.
Phase 1 (voting phase):
Phase 2 (completion according to outcome of vote):
(b) otherwise coordinator decides to abort and sends doAbort to all participants that voted Yes.
Recall that server may crash