written 2.6 years ago by |
Distributed Transactions
- Transaction may access data at several sites.
Each site hasalocal transaction manager responsible for:
Maintaining a log for recovery purposes
Participating in coordinating the concurrent execution of the transactions executing at that site.
Each site has a transaction coordinator, which is responsible for:
- Starting the execution of transactions that originate at the site.
- Distributing subtransactions at appropriate sites for execution.
- Coordinating the termination of each transaction that originates at the site, which may result in the transaction being committed at all sites or aborted at all sites.
System Failure Modes
- Failures unique to distributed systems:
- Failure ofasite.
- Loss of massages
- Handled by network transmission control protocols such as TCP-IP
- Failure ofacommunication link
- Handled by network protocols, by routing messages via alternative links
- Network partition
- A network is said to be partitioned when it has been split into two or more
subsystems that lack any connection between them
- Note:asubsystem may consist ofasingle node
- A network is said to be partitioned when it has been split into two or more
subsystems that lack any connection between them
- Network partitioning and site failures are generally indistinguishable.
Commit Protocols
Commit protocols are used to ensure atomicity across sites
A transaction which executes at multiple sites must either be committed at all the sites, or aborted at all the sites.
not acceptable to haveatransaction committed at one site and aborted at another
The two-phase commit (2PC) protocol is widely used
The three-phase commit (3PC) protocol is more complicated and more expensive, but avoids some drawbacks of two-phase commit protocol. This protocol is not used in practice.
Three Phase Commit (3PC)
Assumptions:
- No network partitioning
- At any point, at least one site must be up.
- At most K sites (participants as well as coordinator) can fail
Phase 1: Obtaining Preliminary Decision: Identical to 2PC Phase 1.
- Every site is ready to commit if instructed to do so.
Phase2 of 2PC is split into 2 phases, Phase 2 and Phase 3 of 3PC
- In phase 2 coordinator makes a decision as in 2PC (called the pre-commit
decision) and records it in multiple (at least K) sites
- In phase 3, coordinator sends commit/abort message to all participating sites,
- In phase 2 coordinator makes a decision as in 2PC (called the pre-commit
decision) and records it in multiple (at least K) sites
- Under 3PC, knowledge of pre-commit decision can be used to commit despite
coordinator failure
- Avoids blocking problem as long as<Ksites fail</li>
- Drawbacks:
- higher overheads
- assumptions may not be satisfied in practice