# Lecture 12 Transactions: Isolation. Transactions What’s hard? – ACID – Concurrency control – Recovery.

## Presentation on theme: "Lecture 12 Transactions: Isolation. Transactions What’s hard? – ACID – Concurrency control – Recovery."— Presentation transcript:

Lecture 12 Transactions: Isolation

Transactions What’s hard? – ACID – Concurrency control – Recovery

View Serializability A particular ordering of instructions in a schedule S is view equivalent to a serial ordering S' iff: Every value read in S is the same value that was read by the same read in S'. The final write of every object is done by the same transaction T in S and S'

Conflict Serializability A schedule is conflict serializable if it is possible to swap non-conflicting operations to derive a serial schedule. For all pairs of conflicting operations {O1 in T1, O2 in T2} either O1 always precedes O2, or O2 always precedes O1.

Precedence Graph Given transactions Ti and Tj, Create an edge from Ti  Tj if: Ti reads/writes some A before Tj writes A, or Ti writes some A before Tj reads A If there are cycles in this graph, schedule is not conflict serializable

Study Break: Serializable Transactions AB Is this schedule conflict serializable? Draw precedence graph. Is it view serializable? T1 R1 R3 W1 W3 T2 W4 W2 R4 R2 T3 R2 R1 W3 T1 R2 W4 W2 R1 T2 R2 W2 R1 W1

Rigorous Two Phase Locking Protocol Before every read, acquire a shared lock Before every write, acquire an exclusive lock (or "upgrade") a shared to an exclusive lock Release locks only after the transaction commits Ensures cascadeless-ness, and that commit order = serialization order

Study Break: 2-Phase Locking Show the locks for the following schedule: T1 R1 W1 R2 W2 T2 R2 W2 Is this a valid 2PL schedule?

Study Break: 2-Phase Locking Solution Show the locks for the following schedule: T1 R1 W1 R2 W2 T2 R2 W2 T1 S1 X1 S2 X2 T2 S2 X2 ===Commit Is this a valid 2PL schedule? Yes.

ACID, In Implementation Source: http://www.bailis.org/blog/when-is-acid-acid-rarely/

Download ppt "Lecture 12 Transactions: Isolation. Transactions What’s hard? – ACID – Concurrency control – Recovery."

Similar presentations