cs4604:introduconto#...

57
CS 4604: Introduc0on to Database Management Systems B. Aditya Prakash Lecture #19: Logging and Recovery 1

Upload: others

Post on 23-Sep-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: CS4604:Introduconto# Database#Management#Systems#courses.cs.vt.edu/~cs4604/Spring14/lectures/lecture-19.pdf · Shadow paging ! keep old pages on disk ! write updated records on new

CS  4604:  Introduc0on  to  Database  Management  Systems  

B.  Aditya  Prakash  Lecture  #19:  Logging  and  Recovery  1  

Page 2: CS4604:Introduconto# Database#Management#Systems#courses.cs.vt.edu/~cs4604/Spring14/lectures/lecture-19.pdf · Shadow paging ! keep old pages on disk ! write updated records on new

General Overview

§  Preliminaries §  Write-Ahead Log - main ideas §  (Shadow paging) §  Write-Ahead Log: ARIES

Prakash  2014   VT  CS  4604   2  

Page 3: CS4604:Introduconto# Database#Management#Systems#courses.cs.vt.edu/~cs4604/Spring14/lectures/lecture-19.pdf · Shadow paging ! keep old pages on disk ! write updated records on new

NOTICE:

§  NONE of the methods in this lecture is used ‘as is’

§  we mention them for clarity, to illustrate the concepts and rationale behind ‘ARIES’, which is the industry standard.

Prakash  2014   VT  CS  4604   3  

Page 4: CS4604:Introduconto# Database#Management#Systems#courses.cs.vt.edu/~cs4604/Spring14/lectures/lecture-19.pdf · Shadow paging ! keep old pages on disk ! write updated records on new

Transactions - dfn

= unit of work, eg. move $10 from savings to checking

Atomicity (all or none) Consistency Isolation (as if alone) Durability

recovery

concurrency control

Prakash  2014   VT  CS  4604   4  

Page 5: CS4604:Introduconto# Database#Management#Systems#courses.cs.vt.edu/~cs4604/Spring14/lectures/lecture-19.pdf · Shadow paging ! keep old pages on disk ! write updated records on new

Overview - recovery

§  problem definition –  types of failures –  types of storage

§  solution#1: Write-ahead log - main ideas – deferred updates –  incremental updates – checkpoints

§  (solution #2: shadow paging)

Prakash  2014   VT  CS  4604   5  

Page 6: CS4604:Introduconto# Database#Management#Systems#courses.cs.vt.edu/~cs4604/Spring14/lectures/lecture-19.pdf · Shadow paging ! keep old pages on disk ! write updated records on new

Recovery

§  Durability - types of failures?

Prakash  2014   VT  CS  4604   6  

Page 7: CS4604:Introduconto# Database#Management#Systems#courses.cs.vt.edu/~cs4604/Spring14/lectures/lecture-19.pdf · Shadow paging ! keep old pages on disk ! write updated records on new

Recovery

§  Durability - types of failures? §  disk crash (ouch!) §  power failure §  software errors (deadlock, division by zero)

Prakash  2014   VT  CS  4604   7  

Page 8: CS4604:Introduconto# Database#Management#Systems#courses.cs.vt.edu/~cs4604/Spring14/lectures/lecture-19.pdf · Shadow paging ! keep old pages on disk ! write updated records on new

Reminder: types of storage

§  volatile (eg., main memory) §  non-volatile (eg., disk, tape) §  “stable” (“never” fails - how to implement it?)

Prakash  2014   VT  CS  4604   8  

Page 9: CS4604:Introduconto# Database#Management#Systems#courses.cs.vt.edu/~cs4604/Spring14/lectures/lecture-19.pdf · Shadow paging ! keep old pages on disk ! write updated records on new

Classification of failures:

§  logical errors (eg., div. by 0) §  system errors (eg. deadlock - pgm can run

later) §  system crash (eg., power failure - volatile

storage is lost) §  disk failure

frequent; ‘cheap’

rare; expensive

Prakash  2014   VT  CS  4604   9  

Page 10: CS4604:Introduconto# Database#Management#Systems#courses.cs.vt.edu/~cs4604/Spring14/lectures/lecture-19.pdf · Shadow paging ! keep old pages on disk ! write updated records on new

Problem definition

§  Records are on disk §  for updates, they are copied in memory §  and flushed back on disk, at the discretion of

the O.S.! (unless forced-output: ‘output(B)’ = fflush())

Prakash  2014   VT  CS  4604   10  

Page 11: CS4604:Introduconto# Database#Management#Systems#courses.cs.vt.edu/~cs4604/Spring14/lectures/lecture-19.pdf · Shadow paging ! keep old pages on disk ! write updated records on new

Problem definition - eg.:

read(X) X=X+1 write(X)

disk main memory

5 }page

buffer{ 5

Prakash  2014   VT  CS  4604   11  

Page 12: CS4604:Introduconto# Database#Management#Systems#courses.cs.vt.edu/~cs4604/Spring14/lectures/lecture-19.pdf · Shadow paging ! keep old pages on disk ! write updated records on new

Problem definition - eg.:

read(X) X=X+1 write(X)

disk main memory

6 5

Prakash  2014   VT  CS  4604   12  

Page 13: CS4604:Introduconto# Database#Management#Systems#courses.cs.vt.edu/~cs4604/Spring14/lectures/lecture-19.pdf · Shadow paging ! keep old pages on disk ! write updated records on new

Problem definition - eg.:

read(X) X=X+1 write(X)

disk

6 5

buffer joins an ouput queue, but it is NOT flushed immediately! Q1: why not? Q2: so what?

Prakash  2014   VT  CS  4604   13  

Page 14: CS4604:Introduconto# Database#Management#Systems#courses.cs.vt.edu/~cs4604/Spring14/lectures/lecture-19.pdf · Shadow paging ! keep old pages on disk ! write updated records on new

Problem definition - eg.:

read(X) read(Y) X=X+1 Y=Y-1 write(X) write(Y)

disk

6

Q2: so what?

X 3

5

Y3

Prakash  2014   VT  CS  4604   14  

Page 15: CS4604:Introduconto# Database#Management#Systems#courses.cs.vt.edu/~cs4604/Spring14/lectures/lecture-19.pdf · Shadow paging ! keep old pages on disk ! write updated records on new

Problem definition - eg.:

read(X) read(Y) X=X+1 Y=Y-1 write(X) write(Y)

disk

6

3

Q2: so what? Q3: how to guard against it?

X 3

5

Y

Prakash  2014   VT  CS  4604   15  

Page 16: CS4604:Introduconto# Database#Management#Systems#courses.cs.vt.edu/~cs4604/Spring14/lectures/lecture-19.pdf · Shadow paging ! keep old pages on disk ! write updated records on new

Overview - recovery

§  problem definition –  types of failures –  types of storage

§  solution#1: Write-ahead log - main ideas – deferred updates –  incremental updates – checkpoints

§  (solution #2: shadow paging)

Prakash  2014   VT  CS  4604   16  

Page 17: CS4604:Introduconto# Database#Management#Systems#courses.cs.vt.edu/~cs4604/Spring14/lectures/lecture-19.pdf · Shadow paging ! keep old pages on disk ! write updated records on new

Solution #1: W.A.L.

§  redundancy, namely §  write-ahead log, on ‘stable’ storage §  Q: what to replicate? (not the full page!!) §  A: §  Q: how exactly?

Prakash  2014   VT  CS  4604   17  

Page 18: CS4604:Introduconto# Database#Management#Systems#courses.cs.vt.edu/~cs4604/Spring14/lectures/lecture-19.pdf · Shadow paging ! keep old pages on disk ! write updated records on new

W.A.L. - intro

§  replicate intentions: eg: <T1 start> <T1, X, 5, 6> <T1, Y, 4, 3> <T1 commit> (or <T1 abort>)

Prakash  2014   VT  CS  4604   18  

Page 19: CS4604:Introduconto# Database#Management#Systems#courses.cs.vt.edu/~cs4604/Spring14/lectures/lecture-19.pdf · Shadow paging ! keep old pages on disk ! write updated records on new

W.A.L. - intro

§  in general: transaction-id, data-item-id, old-value, new-value

§  (assumption: each log record is immediately flushed on stable store)

§  each transaction writes a log record first, before doing the change

§  when done, write a <commit> record & exit

Prakash  2014   VT  CS  4604   19  

Page 20: CS4604:Introduconto# Database#Management#Systems#courses.cs.vt.edu/~cs4604/Spring14/lectures/lecture-19.pdf · Shadow paging ! keep old pages on disk ! write updated records on new

W.A.L. - deferred updates

§  idea: prevent OS from flushing buffers, until (partial) ‘commit’.

§  After a failure, “replay” the log

Prakash  2014   VT  CS  4604   20  

Page 21: CS4604:Introduconto# Database#Management#Systems#courses.cs.vt.edu/~cs4604/Spring14/lectures/lecture-19.pdf · Shadow paging ! keep old pages on disk ! write updated records on new

W.A.L. - deferred updates

§  Q: how, exactly? – value of W on disk? – value of W after recov.? – value of Z on disk? – value of Z after recov.?

<T1 start> <T1, W, 1000, 2000> <T1, Z, 5, 10> <T1 commit>

before

crash

Prakash  2014   VT  CS  4604   21  

Page 22: CS4604:Introduconto# Database#Management#Systems#courses.cs.vt.edu/~cs4604/Spring14/lectures/lecture-19.pdf · Shadow paging ! keep old pages on disk ! write updated records on new

W.A.L. - deferred updates

§  Q: how, exactly? – value of W on disk? – value of W after recov.? – value of Z on disk? – value of Z after recov.?

<T1 start> <T1, W, 1000, 2000> <T1, Z, 5, 10>

before

crash

Prakash  2014   VT  CS  4604   22  

Page 23: CS4604:Introduconto# Database#Management#Systems#courses.cs.vt.edu/~cs4604/Spring14/lectures/lecture-19.pdf · Shadow paging ! keep old pages on disk ! write updated records on new

W.A.L. - deferred updates

§  Thus, the recovery algo: – redo committed transactions –  ignore uncommited ones

<T1 start> <T1, W, 1000, 2000> <T1, Z, 5, 10>

before

crash

Prakash  2014   VT  CS  4604   23  

Page 24: CS4604:Introduconto# Database#Management#Systems#courses.cs.vt.edu/~cs4604/Spring14/lectures/lecture-19.pdf · Shadow paging ! keep old pages on disk ! write updated records on new

W.A.L. - deferred updates

Observations: - no need to keep ‘old’ values - Disadvantages?

<T1 start> <T1, W, 1000, 2000> <T1, Z, 5, 10>

before

crash

Prakash  2014   VT  CS  4604   24  

Page 25: CS4604:Introduconto# Database#Management#Systems#courses.cs.vt.edu/~cs4604/Spring14/lectures/lecture-19.pdf · Shadow paging ! keep old pages on disk ! write updated records on new

W.A.L. - deferred updates

- Disadvantages? (e.g., “increase all balances by 5%”) May run out of buffer space! Hence:

Prakash  2014   VT  CS  4604   25  

Page 26: CS4604:Introduconto# Database#Management#Systems#courses.cs.vt.edu/~cs4604/Spring14/lectures/lecture-19.pdf · Shadow paging ! keep old pages on disk ! write updated records on new

Overview - recovery

§  problem definition –  types of failures –  types of storage

§  solution#1: Write-ahead log – deferred updates –  incremental updates – checkpoints

§  (solution #2: shadow paging)

Prakash  2014   VT  CS  4604   26  

Page 27: CS4604:Introduconto# Database#Management#Systems#courses.cs.vt.edu/~cs4604/Spring14/lectures/lecture-19.pdf · Shadow paging ! keep old pages on disk ! write updated records on new

W.A.L. - incremental updates

- log records have ‘old’ and ‘new’ values. - modified buffers can be flushed at any time Each transaction: - writes a log record first, before doing the

change - writes a ‘commit’ record (if all is well) - exits

Prakash  2014   VT  CS  4604   27  

Page 28: CS4604:Introduconto# Database#Management#Systems#courses.cs.vt.edu/~cs4604/Spring14/lectures/lecture-19.pdf · Shadow paging ! keep old pages on disk ! write updated records on new

W.A.L. - incremental updates

§  Q: how, exactly? – value of W on disk? – value of W after recov.? – value of Z on disk? – value of Z after recov.?

<T1 start> <T1, W, 1000, 2000> <T1, Z, 5, 10> <T1 commit>

before

crash

Prakash  2014   VT  CS  4604   28  

Page 29: CS4604:Introduconto# Database#Management#Systems#courses.cs.vt.edu/~cs4604/Spring14/lectures/lecture-19.pdf · Shadow paging ! keep old pages on disk ! write updated records on new

W.A.L. - incremental updates

§  Q: how, exactly? – value of W on disk? – value of W after recov.? – value of Z on disk? – value of Z after recov.?

<T1 start> <T1, W, 1000, 2000> <T1, Z, 5, 10>

before

crash

Prakash  2014   VT  CS  4604   29  

Page 30: CS4604:Introduconto# Database#Management#Systems#courses.cs.vt.edu/~cs4604/Spring14/lectures/lecture-19.pdf · Shadow paging ! keep old pages on disk ! write updated records on new

W.A.L. - incremental updates

§  Q: recovery algo? §  A:

–  redo committed xacts – undo uncommitted ones

§  (more details: soon)

<T1 start> <T1, W, 1000, 2000> <T1, Z, 5, 10>

before

crash

Prakash  2014   VT  CS  4604   30  

Page 31: CS4604:Introduconto# Database#Management#Systems#courses.cs.vt.edu/~cs4604/Spring14/lectures/lecture-19.pdf · Shadow paging ! keep old pages on disk ! write updated records on new

High level conclusion:

§  Buffer management plays a key role §  FORCE policy: DBMS immediately forces

dirty pages on the disk (easier recovery; poor performance)

§  STEAL policy == ‘incremental updates’: the O.S. is allowed to flush dirty pages on the disk

Prakash  2014   VT  CS  4604   31  

Page 32: CS4604:Introduconto# Database#Management#Systems#courses.cs.vt.edu/~cs4604/Spring14/lectures/lecture-19.pdf · Shadow paging ! keep old pages on disk ! write updated records on new

Buffer Management summary

Force

No Force

No Steal Steal

UNDO REDO

Force

No Force

No Steal Steal

Slowest

Fastest

Performance Implications

Logging/Recovery Implications

No UNDO

No REDO

Prakash  2014   VT  CS  4604   32  

Page 33: CS4604:Introduconto# Database#Management#Systems#courses.cs.vt.edu/~cs4604/Spring14/lectures/lecture-19.pdf · Shadow paging ! keep old pages on disk ! write updated records on new

W.A.L. - incremental updates

Observations §  “increase all balances by

5%” - problems? §  what if the log is huge?

<T1 start> <T1, W, 1000, 2000> <T1, Z, 5, 10>

before

crash

Prakash  2014   VT  CS  4604   33  

Page 34: CS4604:Introduconto# Database#Management#Systems#courses.cs.vt.edu/~cs4604/Spring14/lectures/lecture-19.pdf · Shadow paging ! keep old pages on disk ! write updated records on new

Overview - recovery

§  problem definition –  types of failures –  types of storage

§  solution#1: Write-ahead log – deferred updates –  incremental updates – checkpoints

§  (solution #2: shadow paging)

Prakash  2014   VT  CS  4604   34  

Page 35: CS4604:Introduconto# Database#Management#Systems#courses.cs.vt.edu/~cs4604/Spring14/lectures/lecture-19.pdf · Shadow paging ! keep old pages on disk ! write updated records on new

W.A.L. - check-points

Idea: periodically, flush buffers

Q: should we write anything on the log?

<T1 start> <T1, W, 1000, 2000> <T1, Z, 5, 10> ... <T500, B, 10, 12>

before

crash

Prakash  2014   VT  CS  4604   35  

Page 36: CS4604:Introduconto# Database#Management#Systems#courses.cs.vt.edu/~cs4604/Spring14/lectures/lecture-19.pdf · Shadow paging ! keep old pages on disk ! write updated records on new

W.A.L. - check-points

Q: should we write anything on the log?

A: yes! Q: how does it help us?

<T1 start> <T1, W, 1000, 2000> <T1, Z, 5, 10> <checkpoint> ... <checkpoint> <T500, B, 10, 12>

before

crash

Prakash  2014   VT  CS  4604   36  

Page 37: CS4604:Introduconto# Database#Management#Systems#courses.cs.vt.edu/~cs4604/Spring14/lectures/lecture-19.pdf · Shadow paging ! keep old pages on disk ! write updated records on new

W.A.L. - check-points

Q: how does it help us? A=? on disk? A=? after recovery? B=? on disk? B=? after recovery? C=? on disk? C=? after recovery?

<T1 start> ... <T1 commit> ... <T499, C, 1000, 1200> <checkpoint> <T499 commit> <T500 start> <T500, A, 200, 400> <checkpoint> <T500, B, 10, 12>

before

crash Prakash  2014   VT  CS  4604   37  

Page 38: CS4604:Introduconto# Database#Management#Systems#courses.cs.vt.edu/~cs4604/Spring14/lectures/lecture-19.pdf · Shadow paging ! keep old pages on disk ! write updated records on new

W.A.L. - check-points

Q: how does it help us? I.e., how is the recovery algorithm?

<T1 start> ... <T1 commit> ... <T499, C, 1000, 1200> <checkpoint> <T499 commit> <T500 start> <T500, A, 200, 400> <checkpoint> <T500, B, 10, 12>

crash Prakash  2014   VT  CS  4604   38  

before

Page 39: CS4604:Introduconto# Database#Management#Systems#courses.cs.vt.edu/~cs4604/Spring14/lectures/lecture-19.pdf · Shadow paging ! keep old pages on disk ! write updated records on new

W.A.L. - check-points

Q: how is the recovery algorithm? A:

- undo uncommitted xacts (eg., T500)

- redo the ones committed after the last checkpoint (eg., none)

<T1 start> ... <T1 commit> ... <T499, C, 1000, 1200> <checkpoint> <T499 commit> <T500 start> <T500, A, 200, 400> <checkpoint> <T500, B, 10, 12>

crash Prakash  2014   VT  CS  4604   39  

before

Page 40: CS4604:Introduconto# Database#Management#Systems#courses.cs.vt.edu/~cs4604/Spring14/lectures/lecture-19.pdf · Shadow paging ! keep old pages on disk ! write updated records on new

W.A.L. - w/ concurrent xacts

Assume: strict 2PL

Prakash  2014   VT  CS  4604   40  

Page 41: CS4604:Introduconto# Database#Management#Systems#courses.cs.vt.edu/~cs4604/Spring14/lectures/lecture-19.pdf · Shadow paging ! keep old pages on disk ! write updated records on new

W.A.L. - w/ concurrent xacts

Log helps to rollback transactions (eg., after a deadlock + victim selection)

Eg., rollback(T500): go backwards on log; restore old values

<T1 start>

<checkpoint>

<T499 commit>

<T500 start>

<T500, A, 200, 400>

<T300 commit>

<checkpoint>

<T500, B, 10, 12>

<T500 abort>

before

Prakash  2014   VT  CS  4604   41  

Page 42: CS4604:Introduconto# Database#Management#Systems#courses.cs.vt.edu/~cs4604/Spring14/lectures/lecture-19.pdf · Shadow paging ! keep old pages on disk ! write updated records on new

W.A.L. - w/ concurrent xacts

-recovery algo? - undo uncommitted ones - redo ones committed

after the last checkpoint

<T1 start>

...

<T300 start>

...

<checkpoint>

<T499 commit>

<T500 start>

<T500, A, 200, 400>

<T300 commit>

<checkpoint>

<T500, B, 10, 12>

before

Prakash  2014   VT  CS  4604   42  

Page 43: CS4604:Introduconto# Database#Management#Systems#courses.cs.vt.edu/~cs4604/Spring14/lectures/lecture-19.pdf · Shadow paging ! keep old pages on disk ! write updated records on new

W.A.L. - w/ concurrent xacts

-recovery algo? - undo uncommitted

ones - redo ones

committed after the last checkpoint

- Eg.?

time

T1 T2 T3

T4

ck ck crash

Prakash  2014   VT  CS  4604   43  

Page 44: CS4604:Introduconto# Database#Management#Systems#courses.cs.vt.edu/~cs4604/Spring14/lectures/lecture-19.pdf · Shadow paging ! keep old pages on disk ! write updated records on new

W.A.L. - w/ concurrent xacts

-recovery algo? specifically:

- find latest checkpoint

- create the ‘undo’ and ‘redo’ lists

time

T1 T2 T3

T4

ck ck crash

Prakash  2014   VT  CS  4604   44  

Page 45: CS4604:Introduconto# Database#Management#Systems#courses.cs.vt.edu/~cs4604/Spring14/lectures/lecture-19.pdf · Shadow paging ! keep old pages on disk ! write updated records on new

W.A.L. - w/ concurrent xacts

time

T1 T2 T3

T4

ck ck crash <T1 start> <T2 start> <T4 start> <T1 commit> <checkpoint > <T3 start> <T2 commit> <checkpoint > <T3 commit>

Prakash  2014   VT  CS  4604   45  

Page 46: CS4604:Introduconto# Database#Management#Systems#courses.cs.vt.edu/~cs4604/Spring14/lectures/lecture-19.pdf · Shadow paging ! keep old pages on disk ! write updated records on new

W.A.L. - w/ concurrent xacts <T1 start> <T2 start> <T4 start> <T1 commit> <checkpoint > <T3 start> <T2 commit> <checkpoint > <T3 commit>

<checkpoint> should also contain a list of ‘active’ transactions (= not commited yet)

Prakash  2014   VT  CS  4604   46  

Page 47: CS4604:Introduconto# Database#Management#Systems#courses.cs.vt.edu/~cs4604/Spring14/lectures/lecture-19.pdf · Shadow paging ! keep old pages on disk ! write updated records on new

W.A.L. - w/ concurrent xacts <T1 start> <T2 start> <T4 start> <T1 commit> <checkpoint {T4, T2}> <T3 start> <T2 commit> <checkpoint {T4,T3} > <T3 commit>

<checkpoint> should also contain a list of ‘active’ transactions

Prakash  2014   VT  CS  4604   47  

Page 48: CS4604:Introduconto# Database#Management#Systems#courses.cs.vt.edu/~cs4604/Spring14/lectures/lecture-19.pdf · Shadow paging ! keep old pages on disk ! write updated records on new

W.A.L. - w/ concurrent xacts <T1 start> <T2 start> <T4 start> <T1 commit> <checkpoint {T4, T2}> <T3 start> <T2 commit> <checkpoint {T4,T3} > <T3 commit>

Recovery algo: - build ‘undo’ and ‘redo’ lists - scan backwards, undoing ops by the ‘undo’-list transactions - go to most recent checkpoint - scan forward, re-doing ops by the ‘redo’-list xacts

Prakash  2014   VT  CS  4604   48  

Page 49: CS4604:Introduconto# Database#Management#Systems#courses.cs.vt.edu/~cs4604/Spring14/lectures/lecture-19.pdf · Shadow paging ! keep old pages on disk ! write updated records on new

W.A.L. - w/ concurrent xacts <T1 start> <T2 start> <T4 start> <T1 commit> <checkpoint {T4, T2}> <T3 start> <T2 commit> <checkpoint {T4,T3} > <T3 commit>

Recovery algo: - build ‘undo’ and ‘redo’ lists - scan backwards, undoing ops by the ‘undo’-list transactions - go to most recent checkpoint - scan forward, re-doing ops by the ‘redo’-list xacts

Actual ARIES algorithm: more clever (and more complicated) than that

swap?

Prakash  2014   VT  CS  4604   49  

Page 50: CS4604:Introduconto# Database#Management#Systems#courses.cs.vt.edu/~cs4604/Spring14/lectures/lecture-19.pdf · Shadow paging ! keep old pages on disk ! write updated records on new

W.A.L. - w/ concurrent xacts <T1 start> <T2 start> <T4 start> <T1 commit> <checkpoint {T4, T2}> <T3 start> <T2 commit> <checkpoint {T4,T3} > <T3 commit>

Observations/Questions 1) what is the right order to undo/redo? 2) during checkpoints: assume that no changes are allowed by xacts (otherwise, ‘fuzzy checkpoints’) 3) recovery algo: must be idempotent (ie., can work, even if there is a failure during recovery! 4) how to handle buffers of stable storage?

Prakash  2014   VT  CS  4604   50  

Page 51: CS4604:Introduconto# Database#Management#Systems#courses.cs.vt.edu/~cs4604/Spring14/lectures/lecture-19.pdf · Shadow paging ! keep old pages on disk ! write updated records on new

Observations ARIES (coming up soon) handles all issues: 1) redo everything; undo after that 2) ‘fuzzy checkpoints’ 3) idempotent recovery 4) buffer log records;

–  flush all necessary log records before a page is written

–  flush all necessary log records before a x-act commits

Prakash  2014   VT  CS  4604   51  

Page 52: CS4604:Introduconto# Database#Management#Systems#courses.cs.vt.edu/~cs4604/Spring14/lectures/lecture-19.pdf · Shadow paging ! keep old pages on disk ! write updated records on new

Overview - recovery

§  problem definition –  types of failures –  types of storage

§  solution#1: Write-ahead log – deferred updates –  incremental updates – checkpoints

§  (solution #2: shadow paging)

Prakash  2014   VT  CS  4604   52  

Page 53: CS4604:Introduconto# Database#Management#Systems#courses.cs.vt.edu/~cs4604/Spring14/lectures/lecture-19.pdf · Shadow paging ! keep old pages on disk ! write updated records on new

Shadow paging

§  keep old pages on disk §  write updated records on new pages on disk §  if successful, release old pages; else release ‘new’ pages

§  tried in early IBM prototype systems, but §  not used in practice - why not?

NOT USED

Prakash  2014   VT  CS  4604   53  

Page 54: CS4604:Introduconto# Database#Management#Systems#courses.cs.vt.edu/~cs4604/Spring14/lectures/lecture-19.pdf · Shadow paging ! keep old pages on disk ! write updated records on new

Shadow paging

§  not used in practice - why not? §  may need too much disk space (“increase all

by 5%”) §  may destroy clustering/contiguity of pages.

Prakash  2014   VT  CS  4604   54  

Page 55: CS4604:Introduconto# Database#Management#Systems#courses.cs.vt.edu/~cs4604/Spring14/lectures/lecture-19.pdf · Shadow paging ! keep old pages on disk ! write updated records on new

Other topics

§  against loss of non-volatile storage: dumps of the whole database on stable storage.

Prakash  2014   VT  CS  4604   55  

Page 56: CS4604:Introduconto# Database#Management#Systems#courses.cs.vt.edu/~cs4604/Spring14/lectures/lecture-19.pdf · Shadow paging ! keep old pages on disk ! write updated records on new

Conclusions

§  Write-Ahead Log, for loss of volatile storage, §  with incremental updates (STEAL, NO

FORCE) §  and checkpoints §  On recovery: undo uncommitted; redo

committed transactions.

Prakash  2014   VT  CS  4604   56  

Page 57: CS4604:Introduconto# Database#Management#Systems#courses.cs.vt.edu/~cs4604/Spring14/lectures/lecture-19.pdf · Shadow paging ! keep old pages on disk ! write updated records on new

Next time:

ARIES, with full details on –  fuzzy checkpoints –  recovery algorithm

Prakash  2014   VT  CS  4604   57