1 / 9

Logging

slides online at http://web.mit.edu/6.033/www/assignments/lec17.[ppt|pdf]. Logging. 6.033 Spring 2010 Lecture 17 Sam Madden. Key concepts: Logging for all-or-nothing atomicity Write ahead logging Checkpoints. Shadow Copy Commit. //in memory copy of DB, some records dirty commit(DB):

merv
Download Presentation

Logging

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. slides online at http://web.mit.edu/6.033/www/assignments/lec17.[ppt|pdf] Logging 6.033 Spring 2010 Lecture 17 Sam Madden Key concepts: Logging for all-or-nothing atomicity Write ahead logging Checkpoints

  2. Shadow Copy Commit //in memory copy of DB, some records dirty commit(DB): copy(DB, DBnew) for each record r in memory: if r is dirty: write r into DBnew rename(DBnew, DB) //commit point! // rename must be atomic!

  3. Read with just a log // log is array of records with (type,TID,var,before,after) read(var, log): cset = { } for r in log[len-1] ... log[0]: if (r.type == commit): cset = cset U r.TID if (r.type == update): if (r.TID in cset and r.var == var): return r.after

  4. Read & write with cell storage read(var): return read(cell-storage, var) write(TID,var,newval): append(log,TID,var,read(var),newval) write(cell-storage,var,newval)

  5. Recover with cell-storage and log recover(log): doneset = { } for each record r in log[len-1] ... log[0]: //UNDO if r.type == commit or r.type == abort doneset = doneset U r.TID if r.type == update and r.TID not in doneset: write(cell-storage, r.var, r.before)

  6. Read with cache & cell-storage read(var): if var in cache: return cache[var] else: val = read(cell-storage, var) add (var,val) to cache // possibly evict other // cached values return val write(var,val): append(log,TID, var, cell-storage(var), newval) add (var,val) to cache

  7. Recover with cell-storage, log, and cache recover(log): doneset = { } for each record r in log[len-1] ... log[0]: //UNDO if r.type == commit or r.type == abort doneset = doneset U r.TID if r.type == update and r.TID not in doneset: write(cell-storage, r.var, r.before) for each record r in log[0]...log[len-1]: //REDO if r.type == update and r.TID in doneset: write(cell-storage, r.var, r.after)

  8. REDO Optimization for each record r in log[0]...log[len-1]: //REDO if r.type == update and r.TID in doneset: if (cell-storage does not reflect r) write(cell-storage, r.var, r.after) Log Sequence Number (LSN) is a unique increasing identifier for log records Cell Storage Page LSN | TID | Op | Before | After LSN Log Record Data Do write only if Page.LSN < Record.LSN On write, update LSN

More Related