lect(7) Transaction Management (2).pptx

Full Transcript

Database Management Systems Transaction Management Overview Chapter 18 Part(2) Anomalies with Interleaved Execution Anomalies (Cont’d) Overwriting Uncommitted Data (WW Conflicts): T1: W(A), W(B), C T2: W(A), W(B), C Lock...

Database Management Systems Transaction Management Overview Chapter 18 Part(2) Anomalies with Interleaved Execution Anomalies (Cont’d) Overwriting Uncommitted Data (WW Conflicts): T1: W(A), W(B), C T2: W(A), W(B), C Lock-Based Concurrency Control Strict Two-phase Locking (Strict 2PL) Protocol: – Each Xact must obtain a S (shared) lock on object before reading,  and an X (exclusive) lock on object before writing. − All locks are released when the transaction completes − If an Xact holds an X lock on an object, no other Xact can get a lock (S or X) on that object. Strict 2PL allows only serializable schedules. Aborting a Transaction If a transaction Ti is aborted, all its actions have to be undone. Not only that, if Tj reads an object last written by Ti, Tj must be aborted as well! Most systems avoid such cascading aborts by releasing a transaction’s locks only at commit time. If Ti writes an object, Tj can read this only after Ti commits. Aborting a Transaction In order to undo the actions of an aborted transaction, the DBMS maintains a log in which every write is recorded. This mechanism is also used to recover from system crashes: all active Xacts at the time of the crash are aborted when the system comes back up. The Log The following actions are recorded in the log: − Ti writes an object: the old value and the new value. Log record must go to disk before the changed page! −Ti commits/aborts: a log record indicating this action. The Log cont’d Log records are chained together by Xact id, so it’s easy to undo a specific Xact. Log is often duplexed and archived on stable storage. Recovering From a Crash There are 3 phases in the Aries recovery algorithm: Analysis: Scan the log forward (from the most recent checkpoint) to identify all active Xacts and all dirty pages. Redo: Redoes all updates to dirty pages in the buffer pool. Undo: The writes of all Xacts that were active at the crash are undone

Use Quizgecko on...
Browser
Browser