






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!







-^
-^
Commit - by writing a commit record to the log and^ flushing the log (satisfies the Redo Rule)
Abort - by using the transaction’s log records to restorebefore-images
Restart - by scanning the log and undoing and redoingoperations as necessary
-^
-^
-^
-^
-^
If each data mgr isn’t using its log’s update bandwidth,then a shared log saves log flushes
A good idea, but rarely supported commercially
To implement the Write-Ahead Log Protocol, tag eachcache slot with the log sequence number (LSN) of the lastupdate record to that slot’s page. Page
Dirty
Cache
Pin
Bit
Address
Count
47
21
Log Start^ End
On diskMainMemory
Cache manager won’t flush a page P until P’s last updatedrecord, pointed to by LSN, is on disk.
-^
P’s last log record is usually stable before Flush(P),so this rarely costs an extra flush
-^
LSN must be updated while latch is held on P’s slot
-^
-^
How do you find the end?
-^
-^
-^
if P is not in the recovered-page-list then
add P to the recovered-page-list
-^
if T is in the commit list, then redo the update,else undo the update
-^
Starting with the last checkpoint, scan forward in thelog.
Redo all update records. Process all aborts.^ Maintain list of active transactions (initialized to contentof checkpoint record).
After you’re done scanning, abort all active transactions
-^
-^
-^
Make checkpoints cheap by avoiding synchronized flushingof dirty cache at checkpoint time.^ –
Stop accepting new update, commit, and abortoperations
Make a list of all dirty pages in cache
Make list of [active transaction, pointer to last logrecord]
Append a checkpoint record to log; include the list
Resume normal processing
Initiate low priority flush of all dirty pages
-^
Don’t checkpoint again until all of the last checkpoint’sdirty pages are flushed
-^
Restart begins at second
Each database page P’s header has the LSN of the last logrecord whose operation updated P.
-^
Restart compares log record and page LSN before redoingthe log record’s update U.^ –
Redo the update only if LSN(P) < LSN(U)
-^
Undo is a problem. If U’s transaction aborts and you undoU, what LSN to put on the page?^ –
Suppose T
1
and T
2
update records x and y on P
w
[x] w 1
[y] c 2
2
a^1
(what LSN does a
1
put on P?)
not LSN before w
[x] (which says w 1
[y] didn’t run) 2
not w
[y] (which says w 2
[x] wasn’t aborted) 1