360 likes | 1.76k Views
WA,B. WC. 1. CRASH. WD. WA. 2. WB. WE. 3. CP. Flush. ARIES Example. ARIES - What is Logged. “Physiological Logging” REDO Records Updates to data pages and index pages are logged separately But may use operational logging (e.g., INCREMENT/DECREMENT)
E N D
WA,B WC 1 CRASH WD WA 2 WB WE 3 CP Flush ARIES Example
ARIES - What is Logged • “Physiological Logging” • REDO Records • Updates to data pages and index pages are logged separately • But may use operational logging (e.g., INCREMENT/DECREMENT) • Because escrow locks allow multiple writers • UNDO Records are Purely Logical • Only one record for index and data pages • May use operational logging
WA,B WC 1 CRASH WD WA 2 WB WE 3 CP Flush ARIES Data Structures xactionTable dirtyPgTable Checkpoint Disk
Crash Recovery • 3 Phases • Analysis • Rebuild data structures • Determine winners & losers • Redo • “Repeat history” • Why? • Undo • Undo Losers
Analysis Disk xactionTable dirtyPgTable
Analysis Disk xactionTable dirtyPgTable
Analysis Disk xactionTable dirtyPgTable
Analysis Disk xactionTable dirtyPgTable
Analysis Disk xactionTable dirtyPgTable
Not the same as just before crash (note disk state) Analysis dirtyPgTable Disk xactionTable Losers
Redo dirtyPgTable • Where to begin? • Checkpoint? • Min(recLSN)! • What to REDO • Everything? • Slow • Problematic if using operational (escrow) logging • Redo an update UNLESS: 1. 2. 3. Disk
Redo Example DirtyPgTable • Redo UNLESS • Page is not in dirtyPgTable • If LSN < recLSN • If LSN <= pageLSN Disk
Redo Example DirtyPgTable • Redo UNLESS • Page is not in dirtyPgTable • If LSN < recLSN • If LSN <= pageLSN Disk
Redo Example DirtyPgTable • Redo UNLESS • Page is not in dirtyPgTable • If LSN < recLSN • If LSN <= pageLSN Disk
Redo Example DirtyPgTable • Redo UNLESS • Page is not in dirtyPgTable • If LSN < recLSN • If LSN <= pageLSN Disk
Redo Example DirtyPgTable • Redo UNLESS • Page is not in dirtyPgTable • If LSN < recLSN • If LSN <= pageLSN Disk
Redo Example DirtyPgTable • Redo UNLESS • Page is not in dirtyPgTable • If LSN < recLSN • If LSN <= pageLSN Disk
Redo Example DirtyPgTable • Redo UNLESS • Page is not in dirtyPgTable • If LSN < recLSN • If LSN <= pageLSN Disk State identical to pre-crash state
Undo • Walk backwards, following prevLSNs to UNDO losers xactionTable
Undo • Walk backwards, following prevLSNs to UNDO losers xactionTable
Undo • Walk backwards, following prevLSNs to UNDO losers xactionTable • Why can we just blindly apply UNDOs?
UNDO Wrinkles • Logical UNDO • Why? • “Compensation Log Records” -- CLRs • Avoid repeating UNDO work • Why?
UNDO with CLR Losers: 3
REDO with CLR • REDO CLRs on crash recovery • Use REDO rules to check if updates in CLRs have already been done • After processing CLR, update lastLSN field in dirtyPgTable to point to prevLSN of CLR • Allows UNDO to start from the right place