Docsity

Logging Undo Operations in Database Systems, Slides of Fundamentals of E-Commerce

Partial preview of the text

Download Logging Undo Operations in Database Systems and more Slides Fundamentals of E-Commerce in PDF only on Docsity!

LSN-based logging (cont’d)

-^

w

[x] w 1

[y] c 2

2

a

1

(what LSN does a

1

put on P?)

-^

Why not use a

’s LSN? 1

must latch all of T

’s updated pages before logging a 1

1

else, some w

[z] on P could be logged after a 3

1

but be

executed before a

, leaving a 1

’s LSN on P instead of 1

w

[z]’s. 3

Docsity.com

Logging Undo’s

•^

Log the undo(U) operation, and use its LSN on P^ –

CLR = Compensation Log Record = a logged undo

Do this for all undo’s (during normal abort or recovery)

-^

This preserves the invariant that the LSN on each page Pexactly describes P’s state relative to the log.^ –

P contains all updates to P up to and including the LSNon P, and no updates with larger LSN.

-^

So every aborted transaction’s log is a palindromeof update records and undo records.

-^

Restart processes Commit and Abort the same way^ –

It redoes the transaction’s log records.

It only aborts active transactions after the forward scan

Restart Algorithm (rev 3)

•^

Starting with the last checkpoint, scan forward in the log.^ –

Maintain list of active transactions (initialized to contentof checkpoint record).

Redo an update record U for page P only ifLSN(P) < LSN(U).

After you’re done scanning, abort all active transactions.Log undos while aborting. Log an abort record whenyou’re done aborting.

-^

This style of record logging, logging undo’s, andreplaying history during restart was popularized inthe ARIES algorithm by Mohan et al at IBM.

Analysis Pass

-^

Log flush record after a flush occurs (to avoid redo)

-^

To improve redo efficiency, pre-analyze the log^ –

Requires accessing only the log, not the database

-^

Build a Dirty Page Table that contains list of dirtypages and, for each page, the oldestLSN that mustbe redone^ –

Flush(P) says to delete P from Dirty Page Table

Write(P) adds P to Dirty Page Table, if it isn’t there

Include Dirty Page Table in checkpoint records

Start at checkpt record, scan forward building the table

-^

Also build list of active txns with lastLSN

Logging B-Tree Operations

-^

To split a page^ –

log records deleted from the first page (for undo)

log records inserted to the second page (for redo)

they’re the same records, so long them once!

-^

This doubles the amount of log used for inserts^ –

log the inserted data when the record is first inserted

if a page has N records, log N/2 records, every time apage is split, which occurs once for every N/2 insertions

User-level Optimizations

-^

If checkpoint frequency is controllable,then run some experiments

-^

Partition DB across more disks to reducerestart time (if Restart is multithreaded)

-^

Increase resources (e.g. cache) available torestart program.

Shared Disk System

-^

When a process sets the lock, it tells the lockmanager version number of its cached page.

-^

A process increments the version number thefirst time it updates a cached page.

-^

When a process is done with an updated page, itflushes the page to disk and then incrementsversion number in the lock.