Chapter 14 Transactions Yonsei University 1 st Semester, 2015 Sanghyun Park.

Slides:



Advertisements
Similar presentations
1 Integrity Ioan Despi Transactions: transaction concept, transaction state implementation of atomicity and durability concurrent executions serializability,
Advertisements

Chapter 15: Transactions Transaction Concept Transaction Concept Concurrent Executions Concurrent Executions Serializability Serializability Testing for.
Chapter 16: Transaction Management
Chapter 7 Transactions 7.1 Transaction Concept 7.2 Transaction State 7.3 Implementation of Atomicity and Durability 7.4 Concurrent Executions 7.5 Serializability.
©Silberschatz, Korth and Sudarshan15.1Database System ConceptsTransactions Transaction Concept Transaction State Implementation of Atomicity and Durability.
Transaction Processing IS698 Min Song. 2 What is a Transaction?  When an event in the real world changes the state of the enterprise, a transaction is.
Chapter 8 : Transaction Management. u Function and importance of transactions. u Properties of transactions. u Concurrency Control – Meaning of serializability.
Database System Concepts, 5th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 15: Transactions.
Database Management Systems I Alex Coman, Winter 2006
©Silberschatz, Korth and Sudarshan15.1Database System Concepts Chapter 15: Transactions Transaction Concept Transaction State Implementation of Atomicity.
©Silberschatz, Korth and Sudarshan15.1Database System Concepts Chapter 15: Transactions Transaction Concept Transaction State Implementation of Atomicity.
Database System Concepts, 5th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Transactions.
Transaction Management WXES 2103 Database. Content What is transaction Transaction properties Transaction management with SQL Transaction log DBMS Transaction.
Database System Concepts, 6 th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 14: Transactions.
Transactions Sylvia Huang CS 157B. Transaction A transaction is a unit of program execution that accesses and possibly updates various data items. A transaction.
TRANSACTIONS. Objectives Transaction Concept Transaction State Concurrent Executions Serializability Recoverability Implementation of Isolation Transaction.
Transactions Chapter 14 Transaction Concept A Simple Transaction Model Storage Structure Transaction Atomicity & Durability Transaction Isolation Serializability.
International Computer Institute, Izmir, Turkey Transactions Asst. Prof. Dr. İlker Kocabaş UBİ502 at
Database System Concepts, 5th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 15: Transactions.
Transactions. Chapter 14: Transactions Transaction Concept Transaction State Concurrent Executions Serializability Recoverability Implementation of Isolation.
Lecture 7- Transactions Advanced Databases Masood Niazi Torshiz Islamic Azad University- Mashhad Branch
Database System Concepts, 5th Ed. ©Silberschatz, Korth and Sudarshan Chapter 15: Transactions.
Transaction Lectured by, Jesmin Akhter, Assistant professor, IIT, JU.
Database System Concepts, 5th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 15: Transactions.
1 Transactions. 2 Transaction Concept A transaction is a unit of program execution that accesses and possibly updates various data items. E.g. transaction.
Database System Concepts, 5th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 15: Transactions.
Chapter 15: Transactions
Database System Concepts, 5th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 15: Transactions.
Database System Concepts ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 15: Transactions.
Database System Concepts, 5th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com ICOM 5016 – Introduction.
©Silberschatz, Korth and Sudarshan15.1Database System Concepts Chapter 15: Transactions Transaction Concept Transaction State Implementation of Atomicity.
Database Techniek Lecture 4: Transactions (Chapter 13/15)
©Silberschatz, Korth and Sudarshan15.1Database System Concepts Chapter 15: Transactions Transaction Concept Transaction State Implementation of Atomicity.
Database System Concepts, 5th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 15: Transactions.
Chapter 15: Transactions Loc Hoang CS 157B. Definition n A transaction is a discrete unit of work that must be completely processed or not processed at.
Computing & Information Sciences Kansas State University Wednesday, 05 Nov 2008CIS 560: Database System Concepts Lecture 28 of 42 Wednesday, 05 November.
Chapter 15: Transactions Transaction Concept Transaction State Implementation of Atomicity and Durability Concurrent Executions Serializability Recoverability.
15.1 Transaction Concept A transaction is a unit of program execution that accesses and possibly updates various data items. E.g. transaction to transfer.
©Silberschatz, Korth and Sudarshan14.1Database System Concepts - 6 th Edition Chapter 14: Transactions Transaction Concept Transaction State Concurrent.
Database System Concepts, 5th Ed. Bin Mu at Tongji University Chapter 15: Transactions.
Database System Concepts, 6 th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 14: Transactions.
Software System Lab. Transactions Transaction Concept A transaction is a unit of program execution that accesses and possibly updates various.
D ATABASE A DMINISTRATION L ECTURE N O 5 Muhammad Abrar.
Database System Concepts, 6 th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 14: Transactions.
Chapter 14: Transactions
Chapter 15: Transactions
Chapter 15: Transactions
Chapter 14: Transactions
Chapter 13: Transactions
Database Management System
Part- A Transaction Management
Transactions.
Transactions.
Chapter 15: Transactions
Transactions Sylvia Huang CS 157B.
Chapter 14: Transactions
Chapter 15: Transactions
Chapter 14: Transactions
Module 15: Transactions.
Chapter 15: Transactions
Chapter 14: Transactions
Chapter 15: Transactions
Chapter 15: Transactions
Chapter 14: Transactions
UNIT -IV Transaction.
Presentation transcript:

Chapter 14 Transactions Yonsei University 1 st Semester, 2015 Sanghyun Park

Outline  Transaction Concept  Transaction State  Implementation of Atomicity and Durability  Concurrent Executions  Serializability  Testing for Serializability

Transaction Concept  A transaction is a unit of program execution that accesses and possibly updates various data items  A transaction must see a consistent database  During transaction execution the database may be inconsistent  When the transaction is committed, the database must be consistent  Two main issues to deal with:  Failures of various kinds, such as hardware failures and system crashes  Concurrent execution of multiple transactions

ACID Properties To preserve integrity of data, the database system must ensure:  Atomicity: either all operations of the transaction are properly reflected in the database or none are  Consistency: execution of a transaction in isolation preserves the consistency of the database  Isolation: although multiple transactions may execute concurrently, each transaction must be unaware of other concurrently executing transactions  Durability: after a transaction completes successfully, the changes it has made to the database persist, even if there are system failures

Example of Fund Transfer (1/2)  Transaction to transfer $50 from account A to account B: 1. read(A) 2. A := A – write(A) 4. read(B) 5. B := B write(B)  Consistency requirement – the sum of A and B is unchanged by the execution of the transaction  Atomicity requirement – if the transaction fails after step 3 and before step 6, the system should ensure that its updates are not reflected in the database, else an inconsistency will result

Example of Fund Transfer (2/2)  Durability requirement – once the user has been notified that the transaction has completed (i.e., the transfer of the $50 has taken place), the updates to the database by the transaction must persist despite failures  Isolation requirement – if between steps 3 and 6, another transaction is allowed to access the partially updated database, it will see an inconsistent database (the sum A+B will be less than it should be) Isolation can be ensured trivially by running transactions serially, that is one after the other. However, executing multiple transactions concurrently has significant benefits, as we will see

Transaction State (1/2)  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  Committed, after successful completion

Transaction State (2/2)

Implementation of Atomicity and Durability (1/2)  The recovery-management component of a database system implements the support for atomicity and durability  The shadow-database scheme:  Assume that only one transaction is active at a time  A pointer called db_pointer always points to the current consistent copy of the database  All updates are made on a shadow copy of the database  In case transaction fails, old consistent copy pointed to by db_pointer can be used, and the shadow copy can be deleted

Implementation of Atomicity and Durability (2/2) The shadow-database scheme:  Useful for text editors, but extremely inefficient for large databases: executing a single transaction requires copying the entire database

Concurrent Executions  Multiple transactions are allowed to run concurrently in the system; Advantages are:  Increased processor and disk utilization  Reduced average response time  Concurrency control schemes  Mechanisms to achieve isolation  Control the interaction among the concurrent transactions in order to prevent them from destroying the consistency of the database

Schedules  Schedules are sequences that indicate the chronological order in which instructions of concurrent transactions are executed  A schedule for a set of transactions must consist of all instructions of those transactions  Schedules must preserve the order in which the instructions appear in each individual transaction

Example Schedules (1/3)  Let T 1 transfer $50 from A to B, and T 2 transfer 10% of the balance from A to B. The following is a serial schedule

Example Schedules (2/3)  The following schedule is not a serial schedule, but it is equivalent to a serial schedule

Example Schedules (3/3)  The following schedule does not preserve the value of the sum A+B

Serializability  Each transaction is assumed to preserve database consistency  Thus serial execution of a set of transactions preserves database consistency  A schedule is serializable if it is equivalent to a serial schedule  Conflict serializable  View serializable  We ignore operations other than read and write instructions

Conflict Serializability (1/3)  Instructions l i and l j of transactions T i and T j respectively, conflict if and only if there exists some item Q accessed by both l i and l j, and at least one of these instructions wrote Q 1. I i = read(Q), I j = read(Q),I i and I j don’t conflict 2. I i = read(Q), I j = write(Q),They conflict 3. I i = write(Q), I j = read(Q),They conflict 4. I i = write(Q), I j = write(Q),They conflict  A conflict between l i and l j forces a temporal order between them  If l i and l j are consecutive in a schedule and they do not conflict, their results would remain the same even if they had been interchanged in the schedule

Conflict Serializability (2/3)  If a schedule S can be transformed into a schedule S’ by a series of swaps of non-conflicting instructions, we say that S and S’ are conflict equivalent  We say that a schedule S is conflict serializable if it is conflict equivalent to a serial schedule  Example of a schedule that is not conflict serializable: T 3 T 4 read(Q) write(Q) write(Q) We are unable to swap instructions in the above schedule to obtain either the serial schedule, or the serial schedule

Conflict Serializability (3/3)  The following schedule can be transformed into a serial schedule where T 2 follows T 1, by series of swaps of non-conflicting instructions. Therefore it is conflict serializable

View Serializability (1/2)  Let S and S’ be two schedules with the same set of transactions. S and S’ are view equivalent if the following three conditions are met for each data item Q:  If transaction T i reads the initial value of Q in schedule S, then transaction T i must also read the initial value of Q in schedule S’  If transaction T i executes read(Q) in schedule S and that value was produced by transaction T j, then transaction T i must also read the value of Q in schedule S’ that was produced by transaction T j  If transaction T i performs the final write(Q) operation in schedule S, then transaction T i must also perform the final write(Q) operation in schedule S’

View Serializability (2/2)  A schedule S is view serializable if it is view equivalent to a serial schedule  Every conflict serializable schedule is also view serializable  A schedule which is view serializable but not conflict serializable:

Testing for Serializability (1/2)  Consider some schedule of a set of transactions T 1, T 2,..., T n  Precedence graph is a direct graph where the vertices represent the transactions  We draw an arc from T i to T j if the two transactions conflict and T i accessed the data item earlier on which the conflict arose  We may label the arc by the item on which the conflict arose x y

Testing for Serializability (2/2)  A schedule is conflict serializable if and only if its precedence graph is acyclic  If precedence graph is acyclic, the serializability order can be obtained by a topological sorting of the graph  The problem of checking if a schedule is view serializable falls in the class of NP-complete problems  However practical algorithms that just check some sufficient conditions for view serializability can still be used