CS411 - Transaction Management - Note 1

Txv and commit t must be written to disk before x is

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: Logging (4 of 13) Transaction Management (37 of 61) Recovery with Undo Log Recovery manager: • Read log from the end; cases: • <COMMIT T>: mark T as completed • <ABORT T>: mark T as completed • <T,X,v>: if T is not completed then write X=v to disk else ignore /* committed or aborted xact. */ • <START T>: ignore Undo Logging (5 of 13) Transaction Management (38 of 61) Recovery with Undo Log … … <T6,X6,v6> … … <START T5> <START T4> <T1,X1,v1> <T5,X5,v5> <T4,X4,v4> <COMMIT T5> <T3,X3,v3> <T2,X2,v2> Undo Logging (6 of 13) Transaction Management (39 of 61) Recovery with Undo Log • Note: all undo commands are idempotent • If we perform them a second time, no harm is done • E.g. if there is a system crash during recovery, simply restart recovery from scratch Undo Logging (7 of 13) Transaction Management (40 of 61) Recovery with Undo Log When do we stop reading the log ? • We cannot stop until we reach the beginning of the log file • This is impractical • Better idea: use checkpointing Undo Logging (8 of 13) Transaction Management (41 of 61) Checkpointing Checkpoint the database periodically • Stop accepting new transactions • Wait until all curent transactions complete • Flush log to disk • Write a <CKPT> log record, flush • Resume transactions Undo Logging (9 of 13) Transaction Management (42 of 61) Undo Recovery with Checkpointing During recovery, Can stop at first <CKPT> Undo Logging (10 of 13) … … <T9,X9,v9> … … (all completed) <CKPT> <START T2> <START T3 <START T5> <START T4> <T1,X1,v1> <T5,X5,v5> <T4,X4,v4> <COMMIT T5> <T3,X3,v3> <T2,X2,v2> other transactions transactions T2,T3,T4,T5 Transaction Management (43 of 61) Nonquiescent Checkpointing • Problem with checkpointing: database freezes during checkpoint • Would like to checkpoint while database is operational • =nonquiescent checkpointing Undo Logging (11 of 13) Transaction Management (44 of 61) Nonquiescent Checkpointing • Write a <START CKPT(T1,…,Tk)> where T1,…,Tk are all active transactions • Continue normal operation • When all of T1,…,Tk have completed, write <END CKPT> Undo Logging (12 of 13) Transaction Management (45 of 61) Undo Recovery with Nonquiescent Checkpointing … … … … … … <START CKPT T4, T5, T6> … … … … <END CKPT> … … … Q: why do we need <END CKPT> ? Undo Logging (13 of 13) earlier completed trans plus T4, T5, T6 T4, T5, T6, plus later transactions later transactions Transaction Management (46 of 61) Redo Logging Redo Logging (0 of 8) Transaction Management (47 of 61) Redo Logging Log records • <START T> = transaction T has begun • <COMMIT T> = T has committed • <ABORT T>= T has aborted • <T,X,v>= T has updated element X, and its new value is v Redo Logging (1 of 8) Transaction Management (48 of 61) Redo- Logging Rules R1: If T modifies X, then both <T,X,v> and &l...
View Full Document

This note was uploaded on 01/28/2014 for the course CS 411 taught by Professor Staff during the Fall '08 term at University of Illinois, Urbana Champaign.

Ask a homework question - tutors are online