Академический Документы
Профессиональный Документы
Культура Документы
Outline
Transaction Management Overview ACID Properties of Transactions Transaction State
Distributed Transactions
Distributed Concurrency Control
Distributed deadlocks
Distributed Recovery Commit Protocols Two phase commit (2PC) Three-Phase Commit (3PC)
accesses and possibly updates various data items. E.g. transaction to transfer Rs.50 from account A to account B:
1. 2. 3. 4. 5. 6. read_from_account(A) A := A 50 write_to_account(A) read_from_account(B) B := B + 50 write_to_account(B)
Failures of various kinds, such as hardware failures and system crashes Concurrent execution of multiple transactions
none are Consistency: If each transaction is consistent, and the database is initially consistent, then it is left consistent Isolation: Transactions are isolated, or protected, from the effects of other scheduled transactions Durability: If a transactions completes successfully, then its effects persist
Qu. Define ACID properties of a database.
Transaction State
Active the initial state; the transaction stays in this state
while it is executing Partially committed after the final statement has been executed. Failed after the discovery that normal execution can no longer proceed. Aborted after the transaction has been rolled back and the database restored to its state prior to the start of the transaction. Two options after it has been aborted:
Transaction State
Lost updates
Consider two transactions A
and B which add 10 and 20 respectively to a value V A and B both take a copy of the original value of V They both change the value in memory A puts back its new value first and then B puts back its new value which immediately overwrites As change A's update is lost!
V 5 5 5 5 5 15 25
Temporary Update
A updates V B uses A's updated value A aborts and V's old value
V 5 20 20
5 5 5
Incorrect Summary
A updates all the values in
Distributed Transactions
In the distributed DBMS, a given
transaction is submitted at some one site, but it can access data at other sites as well. The activity of transaction at a given site as a subtransaction. Distributed transaction must have all four ACID properties. Example: A transaction to book a trip, which consist of booking a flight, a rental car and a hotel.
Qu. Illustrate with example Distributed transaction? Qu. Write a note on Distributed transaction.? OR
of a system distributed over a computer network. In database system and transaction management distributed concurrency control refers to the concurrency control of a distributed database. It also refers to the concurrency control in multidatabase environment. E.g. federated database, grid computing and cloud computing environments. The major goal for distributed concurrency control is distributed serializability.
Lock Management
Lock management can be distributed across sites in many ways:
unlock requests for all objects. Primary copy: One copy of each object is designated as the primary copy. All requests to lock or unlock a copy of this object are handled by the lock manager at the site where the primary copy is stored, regardless of where the copy itself is stored. Fully distributed: Requests to lock or unlock a copy of an object stored at a site are handled by the lock manager at the site where the copy is stored.
Qu. What are the choices for managing locks in distributed databases? Qu. Explain how locks can be distributed across diff sites in Concurrency Control of Distributed DB?
Distributed deadlocks
Distributed deadlocks
A cycle in the global wait-for graph An example Simple resolution A centralized deadlock detector collect latest copy of each servers local wait-for graph construct global wait-for graph find cycles in the global wait-for graph Drawbacks poor availability, lack of fault tolerance, poor scalability cost of collecting information is high
Phantom deadlocks
Phantom deadlocks
An example
at server Y: U request lock V at server X: U release lock for T at global deadlock detector: message from server Y arrives earlier than message from server X, then phantom deadlock happens
Distributed Recovery
Recovery
Restoring the server with the latest committed versions of its objects from permanent storage The task of the recovery manager Save objects in permanent storage (in a recovery file) for committed transactions Restore the servers objects after a crash Reorganize the recovery file to improve the performance of recovery Reclaim storage space ( in the recovery file)
Commit Protocols
How to execute commit for distributed transactions Issue: How to ensure atomicity and durability One-phase commit (1PC): the coordinator communicates with all servers to commit. Problem: a server can not abort a transaction. Two-phase commit (2PC): allow any server to abort its part of a transaction. Commonly used. Three-phase commit (3PC): avoid blocking servers in the presence of coordinator failure. Mostly referred in literature, not in practice.
Consider a distributed transaction involving the participation of a number of processes each running on a different machine, and assuming no failure occur Phase1: The coordinator gets the participants ready to write the results into the database Phase2: Everybody writes the results into database
Coordinator: The process at the site where the transaction
originates and which controls the execution Participant: The process at the other sites that participate in executing the transaction
Qu. Explain how two-phase commit protocol works to commit distributed transaction?
avoid blocking even if the coordinator site fails during recovery. The basic idea is that when the coordinator sends out prepare messages and receives yes votes from all subordinates, it sends all sites a precommit message, rather than a commit message. In 3PC the coordinator effectively postpones the decision to commit until it is sure that enough sites know about the decision to commit; if the coordinator subsequently fails, these sites can communicate with each other and detect that the transaction must be committed
Qu. Describe three-phase commit protocol?
References
21