Final Exam Review Last Lecture R&G - All Chapters Covered The end crowns all, And that old common arbitrator, Time, Will one day end it. William Shakespeare.

Slides:



Advertisements
Similar presentations
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Transaction Management Overview Chapter 16.
Advertisements

Database Systems (資料庫系統)
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Transaction Management Overview Chapter 16.
Transaction Management and Concurrency Control
Crash Recovery John Ortiz. Lecture 22Crash Recovery2 Review: The ACID properties  Atomicity: All actions in the transaction happen, or none happens 
1 Concurrency Control Chapter Conflict Serializable Schedules  Two actions are in conflict if  they operate on the same DB item,  they belong.
Introduction to Database Systems1 Concurrency Control CC.Lecture 1.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Concurrency Control Chapter 17 Sections
CS 440 Database Management Systems Lecture 10: Transaction Management - Recovery 1.
Database Management Systems, 3ed, R. Ramakrishnan and J. Gehrke 1 Crash Recovery Chapter 18.
Crash Recovery, Part 1 If you are going to be in the logging business, one of the things that you have to do is to learn about heavy equipment. Robert.
1 Supplemental Notes: Practical Aspects of Transactions THIS MATERIAL IS OPTIONAL.
© Dennis Shasha, Philippe Bonnet 2001 Log Tuning.
Introduction to Database Systems1 Logging and Recovery CC Lecture 2.
1 Crash Recovery Chapter Review: The ACID properties  A  A tomicity: All actions in the Xact happen, or none happen.  C  C onsistency: If each.
COMP9315: Database System Implementation 1 Crash Recovery Chapter 18 (3 rd Edition)
Transaction Management Overview R & G Chapter 16 There are three side effects of acid. Enhanced long term memory, decreased short term memory, and I forget.
ICS 421 Spring 2010 Transactions & Concurrency Control (i) Asst. Prof. Lipyeow Lim Information & Computer Science Department University of Hawaii at Manoa.
Concurrency Control R &G - Chapter 19 Smile, it is the key that fits the lock of everybody's heart. Anthony J. D'Angelo, The College Blue Book.
Concurrency Control R&G - Chapter 17 Smile, it is the key that fits the lock of everybody's heart. Anthony J. D'Angelo, The College Blue Book.
Transaction Management Overview R & G Chapter 16 There are three side effects of acid. Enhanced long term memory, decreased short term memory, and I forget.
1 Concurrency Control and Recovery Module 6, Lecture 1.
Transaction Management Overview R & G Chapter 16 There are three side effects of acid. Enhanced long term memory, decreased short term memory, and I forget.
1 Transaction Management Overview Yanlei Diao UMass Amherst March 15, 2007 Slides Courtesy of R. Ramakrishnan and J. Gehrke.
Final Exam Review Last Lecture R&G - All Chapters Covered The end crowns all, And that old common arbitrator, Time, Will one day end it. William Shakespeare.
Database Management Systems 1 Logging and Recovery If you are going to be in the logging business, one of the things that you have to do is to learn about.
Transaction Management and Concurre cy Overview R & G Chapter There are three side effects of acid. Enhanced long term memory, decreased short term.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Transaction Management Overview Chapter 16.
1 Transaction Management Overview Chapter Transactions  Concurrent execution of user programs is essential for good DBMS performance.  Because.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Transaction Management Overview Chapter 16.
1 Transaction Management Overview Chapter Transactions  A transaction is the DBMS’s abstract view of a user program: a sequence of reads and writes.
Database Management Systems, 2 nd Edition. R. Ramakrishnan and J. Gehrke1 Transaction Management Overview Chapter 18.
CPSC 461. Goal Goal of this lecture is to study Crash Recovery which is subpart of transaction management in DBMS. Crash recovery in DBMS is achieved.
DatabaseSystems/COMP4910/Spring03/Melikyan1 Crash Recovery.
Concurrency Control and Recovery In real life: users access the database concurrently, and systems crash. Concurrent access to the database also improves.
Database Management Systems, 2 nd Edition. R. Ramakrishnan and J. Gehrke1 Transaction Management Overview Lecture 21 Ramakrishnan - Chapter 18.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Transaction Management Overview Chapter 16.
Concurrency Control R &G - Chapter 19. Transactions Concurrent execution of user programs is essential for good DBMS performance. – Because disk accesses.
Database Systems/COMP4910/Spring05/Melikyan1 Transaction Management Overview Unit 2 Chapter 16.
1 Transaction Management Overview Chapter Transactions  Concurrent execution of user programs is essential for good DBMS performance.  Because.
1 Concurrency Control II: Locking and Isolation Levels.
Database Management Systems, 2 nd Edition. R. Ramakrishnan and J. Gehrke1 Transaction Management Overview Instructor: Xintao Wu.
1 Concurrency Control Lecture 22 Ramakrishnan - Chapter 19.
Transaction Management Overview. Transactions Concurrent execution of user programs is essential for good DBMS performance. – Because disk accesses are.
1 Database Systems ( 資料庫系統 ) December 27, 2004 Chapter 17 By Hao-hua Chu ( 朱浩華 )
Transaction Management and Recovery, 2 nd Edition. R. Ramakrishnan and J. Gehrke1 Transaction Management Overview Chapter 18.
Motivation for Recovery Atomicity: –Transactions may abort (“Rollback”). Durability: –What if DBMS stops running? (Causes?) crash! v Desired Behavior after.
Implementation of Database Systems, Jarek Gryz 1 Crash Recovery Chapter 18.
SIMPLE CONCURRENCY CONTROL. Correctness criteria: The ACID properties A A tomicity: All actions in the Xact happen, or none happen. C C onsistency: If.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Transaction Management Overview Chapter 16.
1 Concurrency Control. 2 Why Have Concurrent Processes? v Better transaction throughput, response time v Done via better utilization of resources: –While.
DURABILITY OF TRANSACTIONS AND CRASH RECOVERY
Crash Recovery Chapter 18
Transaction Management Overview
Transaction Management Overview
Transaction Management
Transaction Management Overview
Crash Recovery Chapter 18
Recovery I: The Log and Write-Ahead Logging
Transaction Management Overview
Transaction Management
Transaction Management Overview
Transaction Management
Transaction Management Overview
Crash Recovery Chapter 18
Database Systems (資料庫系統)
Database Systems (資料庫系統)
Transaction Management Overview
Presentation transcript:

Final Exam Review Last Lecture R&G - All Chapters Covered The end crowns all, And that old common arbitrator, Time, Will one day end it. William Shakespeare. Troilus and Cressida.

Topics Covered Relation algebra/calculus Transactions Concurrency Control Crash Recovery

Relational Algebra: 5 Basic Operations Selection (  ) Selects a subset of rows from relation (horizontal). Projection (  ) Retains only wanted columns from relation (vertical). Cross-product (  ) Allows us to combine two relations. Set-difference ( — ) Tuples in r1, but not in r2. Union (  ) Tuples in r1 and/or in r2. Renaming (  ) E.g.  (C(1 -> sid1, 5 -> sid2), S1 x R1)

Intersect (  ) R  S = R  (R  S) Join Condition Join Equijoin: Special case where c contains only equalities Natural join - Compute R  S - Select rows where attributes that appear in both relations have equal values - Project all unique attributes and one copy of each of the common ones. Compound Operations RS sidR S 

Division example Find the names of sailors who’ve reserved ALL red boats {S1 |  S (S  Sailors  S.sname = S1.sname   B  Boats ( B.color = ‘red’   R(R  Reserves  S.sid = R.sid  B.bid = R.bid)))}  sname ( (  sid, bid Reserves) / (  bid (  color=red Boats)) Sailors)

File Organization: Indexes Indexes, clustered vs. unclustered, dense vs. sparse Understand search keys (vs. key constraints!) 3 alternatives for data entries ÀData record with key value k Á Â –Choice of alternative orthogonal to indexing technique! Clustered/unclustered Dense/sparse

ACID properties of Transaction Executions A A tomicity: All actions in the Xact happen, or none happen. C C onsistency: If each Xact is consistent, and the DB starts consistent, it ends up consistent. II solation: Execution of one Xact is isolated from that of other Xacts. D D urability: If a Xact commits, its effects persist.

Concurrency Control Transaction: basic unit of operation –made up of reads and writes Goal: ACID Transactions A & D are provided by Crash Recovery C & I are provided by Concurrency Control Bottom line: reads and writes for various transactions MUST be ordered such that the final state of the database is the same as some serial ordering of the transactions

Scheduling Transactions Serial schedule: Schedule that does not interleave the actions of different transactions. Equivalent schedules: For any database state, the effect (on the set of objects in the database) of executing the first schedule is identical to the effect of executing the second schedule. Serializable schedule: A schedule that is equivalent to some serial execution of the transactions. (Note: If each transaction preserves consistency, every serializable schedule preserves consistency. )

Conflict Serializable Schedules Two schedules are conflict equivalent if: – Involve the same actions of the same transactions – Every pair of conflicting actions is ordered the same way Schedule S is conflict serializable if S is conflict equivalent to some serial schedule

Example A schedule that is not conflict serializable: The cycle in the graph reveals the problem. The output of T1 depends on T2, and vice- versa. T1: R(A), W(A), R(B), W(B) T2: R(A), W(A), R(B), W(B) T1T2 A B Dependency graph

Dependency Graph Dependency graph: One node per Xact; edge from Ti to Tj if an operation of Ti conflicts with an operation of Tj and Ti’s operation appears earlier in the schedule than the conflicting operation of Tj. Theorem: Schedule is conflict serializable if and only if its dependency graph is acyclic

An Aside: View Serializability Schedules S1 and S2 are view equivalent if: – If Ti reads initial value of A in S1, then Ti also reads initial value of A in S2 – If Ti reads value of A written by Tj in S1, then Ti also reads value of A written by Tj in S2 – If Ti writes final value of A in S1, then Ti also writes final value of A in S2 View serializability is “weaker” than conflict serializability! – Every conflict serializable schedule is view serializable, but not vice versa! – I.e. admits more legal schedules T1: R(A) W(A) T2: W(A) T3: W(A) T1: R(A),W(A) T2: W(A) T3: W(A)

Approaches to Concurrency Control 2PL - all objects have Shared and eXclusive locks –once one lock is released, no more locks may be acquired –Strict 2PL: don’t release locks until commit time –Conservative 2PL: acquire all locks at start, release all at end Locking issues –must either prevent or detect deadlock –may want multiple granularity locks (table, page, record) using IS, IX, SIX, S, X locks (check compatibility matrix!) –locking in B-trees usually not 2PL –phantom problem: locking all records of a given criteria (e.g., age > 20)

Other Approaches to CC Multiple granularity locks Optimistic CC Timestamp CC Multiversion CC NOT COVERED in CLASS – NOT ON FINAL

Question from old final - True/False “Our lock manager uses S and X locks, which guarantees that all schedules are conflict- serializable” “Because we use 2PL, deadlocks can never occur” “Because we use Strict 2PL, there will be no cascading aborts”

Question from old final - True/False “Our lock manager uses S and X locks, which guarantees that all schedules are conflict- serializable” “Because we use 2PL, deadlocks can never occur” “Because we use Strict 2PL, there will be no cascading aborts”

More questions.. Read Uncommitted (UR): –Always read data without setting any locks –Always set exclusive locks before writing and hold them until end-of-transaction. Or: No S-Locks, Strict 2-Phase X-Locks. Which of the following conflicts can occur between a UR Xact, and a Strict 2PL Xact: –Write-Write –Read-Write –Write-Read

More questions.. Read Committed (RC): –Obtain locks in the same way as Strict 2PL, and release exclusive locks at the end-of-transaction just like Strict 2PL. Or: RC transactions use Short-Term S-Locks, and Strict 2-Phase X-Locks. Which of the following conflicts can occur between a RC Xact, and a Strict 2PL Xact: –Write-Write –Read-Write –Write-Read

More questions.. All SQL lock modes – even the relaxed modes – use Strict 2-Phase Write Locks. Consider what would happen if a transaction released a shared lock immediately after a read, and released an exclusive lock immediately after a write (Short-Term R-Locks and Short-Term X-Locks). Which of the following could happen in those cases? –Write-Write conflicts. –Inconsistent data in the database –Deadlocks

Crash Recovery ACID - need way to ensure A & D We studied approach of Aries system Buffer management Steal, no Force Every Write to a page is first logged in WAS –log record is in stable storage before data page on disk –log record has Xact#, before value, after value Checkpoints record which pages dirty, which XActs running

Buffer Mgmt Plays a Key Role Force policy – make sure that every update is on disk before commit. –Provides durability without REDO logging. –But, can cause poor performance. No Steal policy – don’t allow buffer-pool frames with uncommited updates to overwrite committed data on disk. –Useful for ensuring atomicity without UNDO logging. –But can cause poor performance. Of course, there are some nasty details for getting Force/NoSteal to work…

Preferred Policy: Steal/No-Force This combination is most complicated but allows for highest performance. NO FORCE (complicates enforcing Durability) –What if system crashes before a modified page written by a committed transaction makes it to disk? –Write as little as possible, in a convenient place, at commit time, to support REDOing modifications. STEAL (complicates enforcing Atomicity) –What if the Xact that performed udpates aborts? –What if system crashes before Xact is finished? –Must remember the old value of P (to support UNDOing the write to page P).

Buffer Management summary Force No Force No Steal Steal No REDO No UNDO UNDO No REDO UNDO REDO No UNDO REDO Force No Force No Steal Steal Slowest Fastest Performance Implications Logging/Recovery Implications

Basic Idea: Logging Record REDO and UNDO information, for every update, in a log. –Sequential writes to log (put it on a separate disk). –Minimal info (diff) written to log, so multiple updates fit in a single log page. Log: An ordered list of REDO/UNDO actions –Log record contains: –and additional control info (which we’ll see soon).

Write-Ahead Logging (WAL) The Write-Ahead Logging Protocol:  Must force the log record for an update before the corresponding data page gets to disk.  Must force all log records for a Xact before commit. (alt. transaction is not committed until all of its log records including its “commit” record are on the stable log.) #1 (with UNDO info) helps guarantee Atomicity. #2 (with REDO info) helps guarantee Durability. This allows us to implement Steal/No-Force Exactly how is logging (and recovery!) done? –We’ll look at the ARIES algorithms from IBM.

Transaction Commit write Commit record to log flush log tail to stable storage remove Xact from Xact table write End record to log

Transaction Abort write Abort record to log go back through log, undoing each write (and add CLR to log) when done, write End record to log

Crash Recovery - 3 phases Analysis: starting from checkpoint, go forward in the log to see: –what pages were dirty –what transactions were active at time of crash Redo: start from oldest transaction that wrote to a dirty page, and redo all writes to dirty pages. Undo: start at the end of the log (time of crash), work backward undoing all writes made by transactions that were active at time of crash –What happens when you encounter a CLR ?