CSL 451 Introduction to Database Systems partially commi ed commi ed active failed aborted Transactions Department of Computer Science and Engineering Indian Institute of Technology Ropar Narayanan (CK) Chatapuram Krishnan!
Summary Transaction Atomicity Consistency Isolation Durability Transaction states active, partially committed, failed, committed, aborted Concurrent executions why? Schedules serial serializable Serializability conflict conflict equivalent conflict serializable Testing for Serializability Precedence graph acyclic topological sorting 2!
Testing for Serializability Consider some schedule of a set of transactions T 1, T 2,..., T n Precedence graph a directed graph where the vertices are the transactions (names). We draw an arc from T i to T j if the two transaction conflict, and T i accessed the data item on which the conflict arose earlier. We may label the arc by the item that was accessed. Example 1 T 1 T 2 Database System Concepts - 6 th Edition 14.3 Silberschatz, Korth and Sudarshan
Test for Conflict Serializability A schedule is conflict serializable if and only if its precedence graph is acyclic. T i Cycle-detection algorithms exist which take order n 2 time, where n is the number of vertices in the graph. (Better algorithms take order n + e where e is the number of edges.) T j T m (a) T k If precedence graph is acyclic, the serializability order can be obtained by a topological sorting of the graph. T i T i This is a linear order consistent with the partial order of the graph. T j T k For example, a serializability order for Schedule A would be T 5 T 1 T 3 T 2 T 4 T k T j T m T m (b) (c) Database System Concepts - 6 th Edition 14.4 Silberschatz, Korth and Sudarshan
Summary Transaction Atomicity Consistency Isolation Durability Transaction states active, partially committed, failed, committed, aborted Concurrent executions why? Schedules serial serializable Serializability conflict conflict equivalent conflict serializable Testing for Serializability Precedence graph acyclic topological sorting Transaction Isolation and Atomicity Partial schedule Recoverable Schedules Cascadeless Schedules cascading rollback Transaction Isolation levels Serializable Repeatable read Read committed Read uncommitted Concurrency control policies locking snapshot isolation 5!
14.1 Suppose that there is a database system that never fails. Is a recovery manager required for this system? 6!
14.4 Justify the following statement: Concurrent execution of transactions is more important when data must be fetched from (slow) disk or when transactions are long, and is less important when data are in memory and transactions are very short. 7!
14.14 Explain the distinction between the terms serial schedule and serializable schedule. 8!
14.15 Consider the following two transactions: T 13 : read(a); T 14 : read(b); if A=0 then B:=B+1; write(b); read(b); read(a); if B:=0 then A:=A+1; write(a); Let the consistency requirement be A=0 V B=0, with A=B=0 the initial values a. Show that every serial execution involving these two transactions preserves the consistency of the database. 9!
14.15 Consider the following two transactions: T 13 : read(a); T 14 : read(b); if A=0 then B:=B+1; write(b); read(b); read(a); if B:=0 then A:=A+1; write(a); Let the consistency requirement be A=0 V B=0, with A=B=0 the initial values b. Show a concurrent execution of the transactions that produces a nonserializable schedule. 10!
14.15 Consider the following two transactions: T 13 : read(a); T 14 : read(b); if A=0 then B:=B+1; write(b); read(b); read(a); if B:=0 then A:=A+1; write(a); Let the consistency requirement be A=0 V B=0, with A=B=0 the initial values c. Is there a concurrent execution of the transactions that produces a serializable schedule? 11!
14.16 Give an example of a serializable schedule with two transactions such that the order in which the transactions commit is different from the serialization order. 12!
14.6 Consider the precedence graph. Is the corresponding schedule conflict serializable? 13!
14.20 Give an example of a schedule that respects the specified level of isolation, but is not serializable. a. Read uncommitted 14!
14.17 What is a recoverable schedule? Why is recoverability of schedules desirable? Are there any circumstances under which it would be desirable to allow nonrecoverable schedules? 15!
14.8 The lost update anomaly is said to occur if a transaction T j reads a data item, then another transaction T k writes the data item. The update performed by T k had been lost, since the update done by T j ignored the value written by T k. a. Give an example of a schedule showing the lost update anomaly. 16!
14.8 The lost update anomaly is said to occur if a transaction T j reads a data item, then another transactions T k writes the data item. The update performed by T k had been lost, since the update done by T j ignored the value written by T k. c. Explain why the lost update anomaly is not possible with the repeatable read isolation level. 17!
14.9 Consider a database for a bank where the database system uses snapshot isolation. Describe a particular scenario in which a nonserializable execution occurs that would present a problem for the bank. 18!