1 / 17

ARIES data structures

ARIES data structures. Log sequence number (LSN) identifies each log record Must be sequentially increasing Each page contains a PageLSN which is the LSN of the last log record whose effects are reflected on the page PageLSN is used during recovery to prevent repeated redo. Cont.

todd-moon
Download Presentation

ARIES data structures

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. ARIES data structures • Log sequence number (LSN) identifies each log record • Must be sequentially increasing • Each page contains a PageLSN which is the LSN of the last log record whose effects are reflected on the page • PageLSNis used during recovery to prevent repeated redo.

  2. Cont. • Each log record contains LSN of previous log record of the same transaction • Special redo-only log record called compensation log record (CLR) used to log actions taken during recovery that never need to be undone • Have a field UndoNextLSN to note next (earlier) record to be undone (next operation to undo). • Required to avoid repeated undo of already undone actions

  3. Log records contain following fields

  4. Transaction Table • During recovery: • initialized during analysis pass from most recent checkpoint • modified during analysis as log records are encountered, and during undo

  5. Cont. • DirtyPageTable • List of pages in the buffer that have been updated • Contains, for each such page • PageLSN of the page • RecLSNis an LSN such that log records before this LSN have already been applied to the page version on disk

  6. ARIES Recovery Algorithm ARIES recovery involves three passes • Analysis pass: Determines • Which transactions to undo • Which pages were dirty (disk version not up to date) at time of crash • RedoLSN: LSN from which redo should start • Redo pass: • Repeats history, redoing all actions from RedoLSN • RecLSN and PageLSNs are used to avoid redoing actions already reflected on page • Undo pass: • Rolls back all incomplete transactions

  7. ARIES Recovery: Analysis Analysis pass • Starts from last complete checkpoint log record • Reads in DirtyPageTable from log record • Sets RedoLSN = min of RecLSNs of all pages in DirtyPageTable • In case no pages are dirty, RedoLSN = checkpoint record’s LSN • Sets undo-list = list of transactions in checkpoint log record • Reads LSN of last log record for each transaction in undo-list from checkpoint log record • Scans forward from checkpoint

  8. Cont. Analysis pass (cont.) • Scans forward from checkpoint • If any log record found for transaction not in undo-list, adds transaction to undo-list • Whenever an update log record is found • If page is not in DirtyPageTable, it is added with RecLSN set to LSN of the update log record • If transaction end log record found, delete transaction from undo-list • At end of analysis pass: • RedoLSN determines where to start redo pass • All transactions in undo-list need to be rolled back

  9. ARIES Redo Pass Redo Pass: Repeats history by replaying every action not already reflected in the page on disk, as follows: • Scans forward from RedoLSN. Whenever an update log record is found: • If the page is not in DirtyPageTable or the LSN of the log record is less than the RecLSN of the page in DirtyPageTable, then skip the log record • Otherwise fetch the page from disk. If the PageLSN of the page fetched from disk is less than the LSN of the log record, redo the log record

  10. ARIES: Undo Pass Undo pass • Performs backward scan on log undoing all transaction in undo-list • Backward scan optimized by skipping unneeded log records as follows: • Next LSN to be undone for each transaction set to LSN of last log record for transaction found by analysis pass. • At each step pick largest of these LSNs to undo, skip back to it and undo it • After undoing a log record • For ordinary log records, set next LSN to be undone for transaction to PrevLSN noted in the log record • For compensation log records (CLRs) set next LSN to be undo to UndoNextLSN noted in the log record • All intervening records are skipped since they would have been undo

  11. Example 1 • After a crash, we find the following log: Analysis phase: Scan forward through the log starting at LSN 0.LSN 5: Initialize XACT table and DPT to empty.LSN 10: Add (T1, LSN 10) to XACT table. Add (P1, LSN 10) to DPT.LSN 15: Set LastLSN=15 for T1 in XACT table. Add (P2, LSN 15) to DPT.LSN 20: Change T1 status to "Commit" in XACT table

  12. Redo phase: Scan forward through the log starting at LSN 10.LSN 10: Read page P1, check PageLSN (LSN of the most recent log record that describes a change to this page) stored in the page. If PageLSN<10, redo LSN 10 (set value to ZZZ) and set the page's PageLSN=10.LSN 15: Read page P2, check PageLSN stored in the page. If PageLSN<15, redo LSN 15 (set value to XXX) and set the page's PageLSN=15. Undo phase: Do nothing; no transactions to undo.

  13. Example 2 • After a crash, we find the following log:

  14. Analysis phase: Scan forward through the log starting at LSN 0.LSN 5: Initialize XACT table and DPT to empty.LSN 10: Add (T1, LSN 10) to XACT table. Add (P1, LSN 10) to DPT.LSN 15: Set LastLSN=15 for T1 in XACT table. Add (P2, LSN 15) to DPT.LSN 20: Add (T2, LSN 20) to XACT table. Add (P3, LSN 20) to DPT.LSN 25: Change T1 status to "Commit" in XACT tableLSN 30: Set LastLSN=30 for T2 in XACT table.

  15. Redo phase: Scan forward through the log starting at LSN 10.LSN 10: Read page P1, check PageLSN stored in the page. If PageLSN<10, redo LSN 10 (set value to ZZZ) and set the page's PageLSN=10.LSN 15: Read page P2, check PageLSN stored in the page. If PageLSN<15, redo LSN 15 (set value to XXX) and set the page's PageLSN=15.LSN 20: Read page P3, check PageLSN stored in the page. If PageLSN<20, redo LSN 20 (set value to VVV) and set the page's PageLSN=20.LSN 30: Read page P1, check PageLSN stored in the page. It will be 10. Redo LSN 30 (set value to TTT) and set the page's PageLSN=30.

  16. Undo phase: T2 must be undone. Put LSN 30 in ToUndo.Write Abort record to log for T2LSN 30: Undo LSN 30 - write a CLR for P1 with "set P1=ZZZ" and undonextLSN=20. LSN 20: Undo LSN 20 - write a CLR for P3 with "set P3=UUU" and undonextLSN=NULL. Write UUU into P3.

More Related