CS411 - Transaction Management - Note 1 - 2

Track all the way back until the beginning of the

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Transaction Management (32 of 61) After a system crash, recovery will use the log to either undo or redo (go back or move on forward). Undo Logging Undo Logging (0 of 13) Transaction Management (33 of 61) Four kinds of log records to remember Undo Logging <Start T> - A transition T has started Log records • <START T> • transaction T has begun <Commit T> - Transition T was committed • <COMMIT T> • T has committed • <ABORT T> <Abort T> - Transaction T was aborted • T has aborted • <T,X,v> • T has updated element X, and its old value was v Undo Logging (1 of 13) Transaction Management (34 of 61) <T,X,v> - Transaction T updated an element X, and the old value was v (this is important because when a we want to undo a step we know the value it was before) These types of log records will be in the log file for system recovery to use Two logging rules to know Undo- Logging Rules U1: If T modifies X, then <T,X,v> entry must be written to log before X is written to disk U2: If T commits, then <COMMIT T> entry must be written to log only after all changes by T are written to disk • Hence: OUTPUTs are done early (before commit) Undo Logging (2 of 13) Transaction Management (35 of 61) U1 – Before writing commit, the old value must be remembered. (To prepare past values). E.g.: When transaction T modifies element X, the log record <T,X,v> needs to be written in the log file before X is written to the disk U2 – If I commit, value must be on the disk already. (To ensure that we have go with the correct data). E.g.: If transaction T commits then the record <COMMIT T> must be in the log file only after all changes by T are written on disk Situation: Imagine a transaction T gets a value X from disk and multiplies it by 2, X = 2X, and then goes back on disk. Where should the commit be? Answer: At the end of the transaction after X is written back to disk. (RULE U2) Before anything is written to disk, there must be a log record. (RULE U1) Timeline of a Transaction T Action T Mem A Mem B Disk A Disk B Log o o o o o <START T> REAT(A,t) 8 8 8 8 t:=t*2 16 8 8 8 WRITE(A,t) 16 16 8 8 READ(B,t) 8 16 8 8 8 t:=t*2 16 16 8 8 8 WRITE(B,t) 16 16 16 8 8 OUTPUT(A) 16 16 16 16 8 OUTPUT(B) 16 16 16 16 <T,A,8> 16 Log - >Rule U1...
View Full Document

Ask a homework question - tutors are online