Distributed Transactions
-
Upload
zitkalasa-ramirez -
Category
Documents
-
view
40 -
download
3
description
Transcript of Distributed Transactions
![Page 1: Distributed Transactions](https://reader035.fdocuments.in/reader035/viewer/2022062217/56812ff5550346895d956c45/html5/thumbnails/1.jpg)
Distributed Transactions
![Page 2: Distributed Transactions](https://reader035.fdocuments.in/reader035/viewer/2022062217/56812ff5550346895d956c45/html5/thumbnails/2.jpg)
Structures of Distributed Transactions
Source: G. Coulouris et al., Distributed Systems: Concepts and Design, Third Edition.
![Page 3: Distributed Transactions](https://reader035.fdocuments.in/reader035/viewer/2022062217/56812ff5550346895d956c45/html5/thumbnails/3.jpg)
A Nested Banking Transaction
Source: G. Coulouris et al., Distributed Systems: Concepts and Design, Third Edition.
![Page 4: Distributed Transactions](https://reader035.fdocuments.in/reader035/viewer/2022062217/56812ff5550346895d956c45/html5/thumbnails/4.jpg)
A Distributed Banking Transaction
Source: G. Coulouris et al., Distributed Systems: Concepts and Design, Third Edition.
![Page 5: Distributed Transactions](https://reader035.fdocuments.in/reader035/viewer/2022062217/56812ff5550346895d956c45/html5/thumbnails/5.jpg)
Atomic Commitment
• When a distributed (flat) transaction comes to an end, either all or none of its operations are carried out.
• Due to atomicity, if one part of a transaction is aborted, then the whole transaction must also be aborted.
![Page 6: Distributed Transactions](https://reader035.fdocuments.in/reader035/viewer/2022062217/56812ff5550346895d956c45/html5/thumbnails/6.jpg)
The Two-Phase Commit Protocol
• The two-phase commit protocol is designed to allow any server to abort its part of a transaction.
• In the first phase, each server votes for the transaction to be committed or aborted.
• In the second phase, every server carries out the joint decision.
![Page 7: Distributed Transactions](https://reader035.fdocuments.in/reader035/viewer/2022062217/56812ff5550346895d956c45/html5/thumbnails/7.jpg)
Operations in the Two-Phase Commit Protocol
Source: G. Coulouris et al., Distributed Systems: Concepts and Design, Third Edition.
![Page 8: Distributed Transactions](https://reader035.fdocuments.in/reader035/viewer/2022062217/56812ff5550346895d956c45/html5/thumbnails/8.jpg)
The Two-Phase Commit Protocol
Source: G. Coulouris et al., Distributed Systems: Concepts and Design, Third Edition.
![Page 9: Distributed Transactions](https://reader035.fdocuments.in/reader035/viewer/2022062217/56812ff5550346895d956c45/html5/thumbnails/9.jpg)
The Two-Phase Commit Protocol (cont’d)
Source: G. Coulouris et al., Distributed Systems: Concepts and Design, Third Edition.
![Page 10: Distributed Transactions](https://reader035.fdocuments.in/reader035/viewer/2022062217/56812ff5550346895d956c45/html5/thumbnails/10.jpg)
Operations for Coordinating Distributed Transactions
Source: G. Coulouris et al., Distributed Systems: Concepts and Design, Third Edition.
![Page 11: Distributed Transactions](https://reader035.fdocuments.in/reader035/viewer/2022062217/56812ff5550346895d956c45/html5/thumbnails/11.jpg)
Atomic Commitment in Nested Transactions
• When a subtransaction completes, it makes an independent decision either to commit provisionally or to abort.
• A parent transaction may commit even if one of its child transactions has aborted.
• Subtransactions will not carry out a real commitment unless the entire nested transaction descides to commit.
![Page 12: Distributed Transactions](https://reader035.fdocuments.in/reader035/viewer/2022062217/56812ff5550346895d956c45/html5/thumbnails/12.jpg)
Atomic Commitment in Nested Transactions (cont’d)
• When a nested transaction provisionally commits, it reports its status and the status of its descendants to its parent.
• When a nested transaction aborts, it just reports abort to its parent.
• Eventually, the top-level transaction receives a list of all the subtransactions (except the descendants of an aborted transaction) in the tree, together with the status of each.
![Page 13: Distributed Transactions](https://reader035.fdocuments.in/reader035/viewer/2022062217/56812ff5550346895d956c45/html5/thumbnails/13.jpg)
Deciding Whether to Commit
Source: G. Coulouris et al., Distributed Systems: Concepts and Design, Third Edition.
![Page 14: Distributed Transactions](https://reader035.fdocuments.in/reader035/viewer/2022062217/56812ff5550346895d956c45/html5/thumbnails/14.jpg)
Two-Phase Commit in Nest Transactions
When a server receives a CanCommit?...
• If it has provisionally committed substractions, then it
* prepares those without aborted ancestors for commitment,
* aborts those with aborted ancestors, and
* sends a Yes vote to the coordinator;
• Otherwise (it must have failed), it sends a No vote.
![Page 15: Distributed Transactions](https://reader035.fdocuments.in/reader035/viewer/2022062217/56812ff5550346895d956c45/html5/thumbnails/15.jpg)
Information for a Nested Transaction
Source: G. Coulouris et al., Distributed Systems: Concepts and Design, Third Edition.
![Page 16: Distributed Transactions](https://reader035.fdocuments.in/reader035/viewer/2022062217/56812ff5550346895d956c45/html5/thumbnails/16.jpg)
Locking
• Each server maintains locks for its own data items.
• Locks cannot be released until the transaction has been committed or aborted at all servers.
• Distributed deadlocks might occur if different servers impose different orderings on transactions.
![Page 17: Distributed Transactions](https://reader035.fdocuments.in/reader035/viewer/2022062217/56812ff5550346895d956c45/html5/thumbnails/17.jpg)
Locking (cont’d)
• Parent transactions are not allowed to run concurrently with their child transactions.
• To acquire a read lock, all holders of write lock on the data item must be ancestors.
• To acquire a write lock, all holders of read and write locks on the data item must be ancestors.
• When a nested transaction commits, its locks are inherited by its parent; when a nested transaction aborts, its locks are removed.
![Page 18: Distributed Transactions](https://reader035.fdocuments.in/reader035/viewer/2022062217/56812ff5550346895d956c45/html5/thumbnails/18.jpg)
Timestamp Ordering
• A globally unique transaction timestamp is issued by the coordinator.
• Conflicts are resolved as each operation is performed.
• If the resolution of a conflict requires a transaction to be aborted, the coordinator will be informed.
![Page 19: Distributed Transactions](https://reader035.fdocuments.in/reader035/viewer/2022062217/56812ff5550346895d956c45/html5/thumbnails/19.jpg)
Optimistic Concurrency Control
• If only one transaction may perform validation at the same time, commitment deadlocks might occur; parallel validation does not have the problem.
• A parallel validation checks (among other things) conflicts between write operations of the transaction being validated against the write operations of other concurrent transactions.
![Page 20: Distributed Transactions](https://reader035.fdocuments.in/reader035/viewer/2022062217/56812ff5550346895d956c45/html5/thumbnails/20.jpg)
Optimistic Concurrency Control (cont’d)
• To ensure that transactions at different servers are globally serializable, the servers may
* conduct a global validation (checking if there is a cyclic ordering) or
* use the same globally unique transaction number for the same transaction.
![Page 21: Distributed Transactions](https://reader035.fdocuments.in/reader035/viewer/2022062217/56812ff5550346895d956c45/html5/thumbnails/21.jpg)
An Interleaving of Three Transactions
Source: G. Coulouris et al., Distributed Systems: Concepts and Design, Third Edition.
![Page 22: Distributed Transactions](https://reader035.fdocuments.in/reader035/viewer/2022062217/56812ff5550346895d956c45/html5/thumbnails/22.jpg)
Distributed Deadlocks
• A cycle in the global wait-for graph (but not in any single local one) represents a distributed deadlock.
• A deadlock that is detected but is not really a deadlock is called a phantom deadlock.
• Two-phase locking prevents phantom deadlocks; autonomous aborts may cause phantom deadlocks.
![Page 23: Distributed Transactions](https://reader035.fdocuments.in/reader035/viewer/2022062217/56812ff5550346895d956c45/html5/thumbnails/23.jpg)
Distributed Deadlocks and Wait-For Graphs
Source: G. Coulouris et al., Distributed Systems: Concepts and Design, Third Edition.
![Page 24: Distributed Transactions](https://reader035.fdocuments.in/reader035/viewer/2022062217/56812ff5550346895d956c45/html5/thumbnails/24.jpg)
Local and Global Wait-For Graphs
Source: G. Coulouris et al., Distributed Systems: Concepts and Design, Third Edition.
![Page 25: Distributed Transactions](https://reader035.fdocuments.in/reader035/viewer/2022062217/56812ff5550346895d956c45/html5/thumbnails/25.jpg)
Edge Chasing
• Initiation: when a server notes that a transaction T starts waiting for another transaction U, which is waiting to access a data item at another server, it sends a probe containing TU to the server of the data item at which transaction U is blocked.
![Page 26: Distributed Transactions](https://reader035.fdocuments.in/reader035/viewer/2022062217/56812ff5550346895d956c45/html5/thumbnails/26.jpg)
Edge Chasing (cont’d)
• Detection: receive probes and decide whether deadlock has occurred and whether to forward the probes.
When a server receives a probe TU and finds the transaction that U is waiting for, say V, is waiting for another data item elsewhere, a probe TUV is forwarded.
• Resolution: select a transaction in the cycle to abort
![Page 27: Distributed Transactions](https://reader035.fdocuments.in/reader035/viewer/2022062217/56812ff5550346895d956c45/html5/thumbnails/27.jpg)
Probes for Detecting Deadlocks
Source: G. Coulouris et al., Distributed Systems: Concepts and Design, Third Edition.
![Page 28: Distributed Transactions](https://reader035.fdocuments.in/reader035/viewer/2022062217/56812ff5550346895d956c45/html5/thumbnails/28.jpg)
Independently Initiated Probes
Source: G. Coulouris et al., Distributed Systems: Concepts and Design, Third Edition.
![Page 29: Distributed Transactions](https://reader035.fdocuments.in/reader035/viewer/2022062217/56812ff5550346895d956c45/html5/thumbnails/29.jpg)
Probes Traveling Downhill
Source: G. Coulouris et al., Distributed Systems: Concepts and Design, Third Edition.
![Page 30: Distributed Transactions](https://reader035.fdocuments.in/reader035/viewer/2022062217/56812ff5550346895d956c45/html5/thumbnails/30.jpg)
Types of Entry in a Recovery File
Source: G. Coulouris et al., Distributed Systems: Concepts and Design, Third Edition.
![Page 31: Distributed Transactions](https://reader035.fdocuments.in/reader035/viewer/2022062217/56812ff5550346895d956c45/html5/thumbnails/31.jpg)
Log for Banking Service
Source: G. Coulouris et al., Distributed Systems: Concepts and Design, Third Edition.
![Page 32: Distributed Transactions](https://reader035.fdocuments.in/reader035/viewer/2022062217/56812ff5550346895d956c45/html5/thumbnails/32.jpg)
Shadow Versions
Source: G. Coulouris et al., Distributed Systems: Concepts and Design, Third Edition.
![Page 33: Distributed Transactions](https://reader035.fdocuments.in/reader035/viewer/2022062217/56812ff5550346895d956c45/html5/thumbnails/33.jpg)
A Log for the Two-Phase Commit Protocol
Source: G. Coulouris et al., Distributed Systems: Concepts and Design, Third Edition.
![Page 34: Distributed Transactions](https://reader035.fdocuments.in/reader035/viewer/2022062217/56812ff5550346895d956c45/html5/thumbnails/34.jpg)
Recovery of the Two-Phase Commit Protocol
Source: G. Coulouris et al., Distributed Systems: Concepts and Design, Third Edition.
![Page 35: Distributed Transactions](https://reader035.fdocuments.in/reader035/viewer/2022062217/56812ff5550346895d956c45/html5/thumbnails/35.jpg)
Recovery of the Two-Phase Commit Protocol
Source: G. Coulouris et al., Distributed Systems: Concepts and Design, Third Edition.