CS411 - Transaction Management - Note 1 - 2

Outputs are done early before commit undo logging 2 of

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: As a programmer you must make sure transaction starts in correct database state and end in correct database state. Also transaction to be atomic because concurrent programming is hard. Transaction Management (29 of 61) Four primitive operations of transactions: We have buffers to ensure the safeness of our transactions Primitive Operations of Transactions • INPUT(X) • read element X to memory buffer • READ(X,t) INPUT(X) – Get element X to memory buffer which is local memory • copy element X to transaction local variable t • WRITE(X,t) • copy transaction local variable t to element X • OUTPUT(X) READ(X, t) – Copy element X to local variable t • write element X to disk Recovery (6 of 8) Transaction Management (30 of 61) WRITE(X, t) – Copy transaction local variable to element X OUTPUT(X) – Write element X to the disk Example of using primitive operations Example READ(A,t); t := t*2; WRITE(A,t); READ(B,t); t := t*2; WRITE(B,t) Action t INPUT(A) Mem A Mem B Disk A Disk B 8 8 8 READ(A,t) 8 8 8 8 t:=t*2 16 8 8 8 WRITE(A,t) 16 16 8 8 INPUT(B) 16 16 8 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 OUTPUT(B) 16 16 16 Everything in the end must be consistent Recovery (7 of 8) 16 8 16 16 Transaction Management (31 of 61) If not consistent, either try to redo the step to go forward or go back to the beginning of the transaction(Try to commit or rollback) Example: This can be wrong when system stops after OUTPUT(A), two values of Disk A and Disk B will no longer be the same. There should be some solution in this kind of case. We use log. The Log • An append- only file containing log records • Note: multiple transactions run concurrently, log records are interleaved • After a system crash, use log to: • Redo some transaction that did commit. • Undo other transactions that did not commit. Log is a special storage, or sequence of history. Only appending is possible when writing on the log file. This should be put in very secure place, and it should never be lost. It is the sequence of records that happened in the transaction. Logging is crucial for undo and redo operations Recovery (8 of 8)...
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