Beruflich Dokumente
Kultur Dokumente
OUTLINE
Motivation Transaction Two
Concepts
Phase Commit
Distributed
Summary
1 MOTIVATION
What happens if a failure occurs during modification of resources? Which operations have been completed? Which operations have not (and have to be done again)? In which states will the resources be?
t6 t7
Time
t6 t7
Time
2 TRANSACTION CONCEPTS
1 ACID Properties
2.1.1 ATOMICITY
Transactions are either performed completely or no modification is done. Start of a transaction is a continuation point to which it can roll back. End of transaction is next continuation point.
2.1.2 CONSISTENCY
Shared resources should always be consistent. Inconsistent states occur during transactions:
Application defines consistency and is responsible for ensuring it is maintained. Transactions can be aborted if they cannot resolve inconsistencies.
2.1.3 ISOLATION
Each transaction accesses resources as if there were no other concurrent transactions. Modifications of the transaction are not visible to other resources before it finishes. Modifications of other transactions are not visible during the transaction at all. Implemented through:
2.1.4 DURABILITY
A completed transaction is always persistent (though values may be changed by later transactions). Modified resources must be held on persistent storage before transaction can complete.
10
Begin:
Commit:
End a transaction. Store changes made during transaction. Make changes accessible to other transactions.
Abort:
End a transaction. Undo all changes made during the transaction.
11
Client Server
12
2.3.1 COORDINATOR
Coordinator plays key role in managing transaction. Coordinator is the component that handles begin / commit / abort transaction calls. Coordinator allocates system-wide unique transaction identifier. Different transactions may have different coordinators.
13
14
15
T
T
T1 T 12 T
21
Client
T2
Y Z T
P
22
16
Flat Transaction
Begin Trans.
Crash
Begin Trans.
Abort
Flat Transaction
Rollbac k
Flat Transaction
Rollbac k
17
Main Transaction
Call
Commit
Commit
Begin Trans.
Commit
Begin Trans.
Commit
18
3 TWO-PHASE COMMIT
19
Yes: it will commit if asked, but does not yet know if it is actually going to commit. No: it immediately aborts its operations.
Hence, servers can unilaterally abort but not unilaterally commit a transaction.
20
22
23
3.2 COMPLEXITY
Assuming N participating servers: (N-1) Voting requests from coordinator to servers. (N-1) Votes from servers to coordinator. At most (N-1) Completion requests from coordinator to servers. (When commit) (N-1) acknowledgement from servers to coordinator. Hence, complexity of requests is linear in the number of participating servers.
24
Top level transaction needs to be able to communicate its decision down to all subtransactions so they may react accordingly.
25
Abort is handled as normal. Provisional commit means that coordinator and transactional servers are willing to commit subtransaction but have not yet done so.
26
11
abort (at M)
12
T21 T
2
aborted (at Y)
22
27
Coordinator of transaction T T1 T2 T 11 T 12 , T 21 T 22
Child transactions T 1, T 2 T 11 , T 12 T 21 , T 22
Participant
Abort list T 11 , T 2 T 11 T2 T 11
28
nested transactions, the top-level transaction plays as coordinator, while participants are all the provisionally committed subtransaction coordinators without aborted ancestors. Hierarchic two-phase commit: a multi-level nested protocol where the coordinator communicates to the immediate child transaction coordinator in a hierarchic fashion. Flat two-phase commit: the coordinator contact all participants with provisional commit directly.
29
should they be prevented as they are different? allowed as they are part of the same transaction?
30
31
Transaction T before Transaction U on server X Transaction U before Transaction T on server Y This is not serially equivalent globally since T before U in one server 32 and U before T in another.
c.deposit(30)
b.withdraw(30)
lock C at Z
33
(b)
W
Waits for
T X
V Y
T U
T V
Phantom deadlock: A deadlock that is detected but is not really a deadlock is called a phantom deadlock. E.g.: Transaction U releases an object at server X and requests the one held by V at server Y. Assuming the 35 latter is first received.
Waits for
A Initiation
W U V X
Waits for
Held by Y
Waits for
36
Waits for
T U
Waits for
U
U
T
W
V
V
W
T W
V W
V
TUWV
VTU
U
TUW
Waits for
V
W
Waits for
37
6 SUMMARY
Transaction concepts:
ACID Transaction commands Roles of distributed components in transactions phase one: voting phase two: completion
Two-phase commit
38