110 likes | 211 Views
CS 603 Distributed Transactions. February 18, 2002. What is a Transaction?. A tomic The external view is that either everything in the transaction happened, or nothing did C onsistent If the start state is valid, the end state is valid I solated
E N D
CS 603Distributed Transactions February 18, 2002
What is a Transaction? • Atomic • The external view is that either everything in the transaction happened, or nothing did • Consistent • If the start state is valid, the end state is valid • Isolated • A transaction in process is not affected by and does not affect any other transaction • Durable • Once complete, the effects of a transaction are permanent, even in the event of failure.
Distributed Transactions • What is the difference with Distributed Transactions? • NOTHING! • Must still support ACID properties • Important for all the same reasons • Why do we study Distributed Transactions? • Some properties harder to implement • Basic single-system techniques not sufficient
What is a Distributed Transaction? Data Data Transaction component Transaction component Transaction component Transaction component Data Data
Why are Distributed Transactions Hard? • Atomic • Different parts of a transaction may be at different sites • How do we ensure all or none committed? • Consistent • Failure may affect only part of transaction • Isolated • Commitment must occur “simultaneously” at all sites • Durable • Not much different when other problems solved • Makes “delayed commit” difficult
Key Issues • Commitment • Standard techniques preserve properties when commit occurs • Distributed systems need commit protocols so we know when commit has occurred • Failures • Standard techniques support durability for commit/abort • What happens if a site fails during commitment?
Committing a Distributed Transaction Data Data Transaction component Transaction component log log Transaction component Transaction component log log Data Data
Two-Phase Commit(Lamport ’76, Gray ’79) • Assumes central coordinator • Coordinator initiates protocol • Participants: entities with actions to be committed/aborted • Phase 1: • Coordinator asks if participants can commit • Participants respond yes/no • Phase 2: • If all votes yes, coordinator sends Commit • Otherwise send Abort • Participants send Have Committed / Have Aborted
Two-Phase Commit Data Data Transaction component Transaction component log log CanCommit? CanCommit? Commit Commit Done Done Yes Yes Coordinator Yes Yes Done Done Commit Commit Transaction component Transaction component log log CanCommit? CanCommit? Data Data
Two-Phase Commit:Fault Tolerance • Participant fails in Phase 1: • Coordinator doesn’t get unanimous yes • Abort • Participant fails in Phase 2: • On reawakening, can ask coordinator if it should commit or abort • Requires that both commit and abort states be durable before sending “yes” vote
Two-Phase Commit:Problems • Blocks on failure • Timeout before abort if participant fails • All participants must wait for recovery if coordinator fails • While blocked, transaction must remain Isolated • Hold locks on data items touched • Prevents other transactions from completing • Solution: Wednesday