CS411 - Transaction Management - Note 1 - 2

Undo logging 13 of 13 earlier completed trans plus t4

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: w(x) - >Rule U2 Commit <T,B,8> Question: What does write mean? <COMMIT T> Undo Logging (3 of 13) Transaction Management (36 of 61) Answer: When buffer is flushed onto the disk Commit can only happen after the disk has been updated Question: suppose we have a crash after output (A) what do we do? Answer: Go back to the beginning and start over Main Purpose of a Log is for Recovery! Recovery with Undo Log After system’s crash, run recovery manager • Idea 1. Decide for each transaction T whether it is completed or not 3 types of transactions o Undo Logging (4 of 13) Transaction Management (37 of 61) <START T><ABORT T> o • Idea 2. Undo all modifications by incompleted transactions <START T><COMMIT T> o • <START T>….<COMMIT T>…. = yes • <START T>….<ABORT T>……. = yes • <START T>……………………… = no <START T> Commit / Abort is good indicator that the transaction successfully ended. If no commit or abort, not a complete transaction and we MUST undo all modifications with incomplete transactions! Recovery with Undo Log Question: Where do we start the undo from? Recovery manager: • Read log from the end; cases: Answer: At the end of the undo log and work backwards with every incomplete transaction • <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) Diagram Example Recovery with Undo Log Start recovering from the bottom to the top. Track all the way back until the beginning of the data. … … <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) From the diagram, only T5 is committed and all the others are partial transactions so we need to undo. We scan from the end of the log and undo T1, T2, T3, T4, and T6. Transaction Management (39 of 61) Question: How far? Answer: As far as the beginning of database which may be a very long time! 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) Key Point: Undo commands are idempotent, which means doing the commands will not harm the database because the end result will be the same Transaction Management (40 of 61) Reading until the beginning of the log file can be inefficient and take up time. 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) Question: How can we solve this issue? Answer: Use of checkpoints Transaction Management (41 of 61) Periodically check when things are complete, concept of a checkpoint 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...
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