Recovery Part 1 Lecture 15
Database Recovery Transactions make ACID properties possible Until now all locking has been abstract objects – What’s the right granularity for locking? Single-level v. multi-level locking
Study Break: Intention Locks T1.IX(Table A) T2.IX(Table A) T1.IX(Page A.1) T2.IX(Page A.1) T1.X(Tuple A.1.1) T2.X(Tuple A.1.2) T1.IX(Table A) T2.IS(Table A) T1.X(Page A.1) T2.IS(Page A.1) T2.S(Tuple A.1.1) Are the following lockings legal? Consider transactions (T1, T2) with X, IX, S, SX locks.
Recovery Cope with crashes Assure that we have atomicity and durability Need to make it s.t. the db is in a consistent state after recovery protocol is run Do this with write ahead logging Buffer pool needs to not interfere w/recovery
Study Break: Logging 3 Transactions (TA, TB, TC) Transaction begins with x = 10, y = 100 After crash, before recovery have y = 200 After recovery have x = 110 What happened? What is the log? Use commit, update, and abort commands TA X = X + 1 Y = Y * 3 TB Y = Y * 2 X = X + 5 TC X = X * 10
Study Break: Logging Solution TransactionTypeItemOld ValueNew Value TAUpdateX1011 TBUpdateY TBAbort TAUpdateY TACommit TCUpdateX11110 TCCommit