Presentation is loading. Please wait.

Presentation is loading. Please wait.

Logging and ARIES. ARIES Example LSNTypeTidPrevLSNData 1SOT1 2UP11A 3 12B 4CP 5SOT3 6UP13C 7SOT2 8UP27D 9EOT16 10UP35B 11UP28A 12EOT211 13UP310E 1 2 3.

Similar presentations


Presentation on theme: "Logging and ARIES. ARIES Example LSNTypeTidPrevLSNData 1SOT1 2UP11A 3 12B 4CP 5SOT3 6UP13C 7SOT2 8UP27D 9EOT16 10UP35B 11UP28A 12EOT211 13UP310E 1 2 3."— Presentation transcript:

1 Logging and ARIES

2 ARIES Example LSNTypeTidPrevLSNData 1SOT1 2UP11A 3 12B 4CP 5SOT3 6UP13C 7SOT2 8UP27D 9EOT16 10UP35B 11UP28A 12EOT211 13UP310E WA,B CP WC WD WB WA WE CRASH Flush

3 ARIES Data Structures WA,B CP WC WD WB WA WE CRASH Flush lastLSNTID 11 xactionTable pgNorecLSN dirtyPgTable xactionTable dirtyPgTable Checkpoint PagepageLSN A? B? C? D? E? Disk lastLSNTID 21 lastLSNTID 31 lastLSNTID lastLSNTID 133 pgNorecLSN A2 B3 pgNorecLSN A2 B3 C6 PagepageLSN A2 B3 C6 D? E? pgNorecLSNpgNorecLSN D8 pgNorecLSN D8 B10 pgNorecLSN D8 B10 A11 pgNorecLSN D8 B10 A11 E13 xactionTable3 - 1 dirtyPgTableA - 2, B - 3

4 Crash Recovery Phases 1.Analysis –Find earliest useful log record –Rebuild xactionTable and dirtyPgTable –Determine winners & losers 2.Redo –Redo all updates, even from losers (“repeat history”) –Why? 3.Undo –Undo Losers

5 Analysis LSNTypeTidPrevLSNData 1SOT1 2UP11A 3 12B 4CP 5SOT3 6UP13C 7SOT2 8UP27D 9EOT16 10UP35B 11UP28A 12EOT211 13UP310E

6 Analysis LSNTypeTidPrevLSNData 5SOT3 6UP13C 7SOT2 8UP27D 9EOT16 10UP35B 11UP28A 12EOT211 13UP310E lastLSNTID 31 pgNorecLSN A2 B3 PagepageLSN A2 B3 C6 D? E? xactionTabledirtyPgTable Disk

7 Analysis LSNTypeTidPrevLSNData 5SOT3 6UP13C 7SOT2 8UP27D 9EOT16 10UP35B 11UP28A 12EOT211 13UP310E lastLSNTID pgNorecLSN A2 B3 PagepageLSN A2 B3 C6 D? E? xactionTabledirtyPgTable Disk

8 Analysis LSNTypeTidPrevLSNData 5SOT3 6UP13C 7SOT2 8UP27D 9EOT16 10UP35B 11UP28A 12EOT211 13UP310E lastLSNTID pgNorecLSN A2 B3 C6 PagepageLSN A2 B3 C6 D? E? xactionTabledirtyPgTable Disk

9 Analysis LSNTypeTidPrevLSNData 5SOT3 6UP13C 7SOT2 8UP27D 9EOT16 10UP35B 11UP28A 12EOT211 13UP310E lastLSNTID pgNorecLSN A2 B3 C6 PagepageLSN A2 B3 C6 D? E? xactionTabledirtyPgTable Disk

10 Analysis LSNTypeTidPrevLSNData 5SOT3 6UP13C 7SOT2 8UP27D 9EOT16 10UP35B 11UP28A 12EOT211 13UP310E lastLSNTID pgNorecLSN A2 B3 C6 D8 PagepageLSN A2 B3 C6 D? E? xactionTabledirtyPgTable Disk

11 Analysis LSNTypeTidPrevLSNData 5SOT3 6UP13C 7SOT2 8UP27D 9EOT16 10UP35B 11UP28A 12EOT211 13UP310E lastLSNTID 133 pgNorecLSN A2 B3 C6 D8 E13 PagepageLSN A2 B3 C6 D? E? xactionTable dirtyPgTable Disk Not the same as just before crash (note disk state)

12 Redo Where to begin? –Checkpoint? –Min(recLSN)! What to REDO? pgNorecLSN A2 B3 C6 D8 E13 dirtyPgTable PagepageLSN A2 B3 C6 D? E? Disk

13 Redo Example LSNTypeTidPrevLSNData 1SOT1 2UP12A 3 13B 4CP 5SOT3 6UP13C 7SOT2 8UP27D 9EOT16 10UP35B 11UP28A 12EOT211 13UP310E pgNorecLSN A2 B3 C6 D8 E13 Redo UNLESS Page is not in dirtyPgTable If LSN < recLSN If LSN <= pageLSN DirtyPgTable PagepageLSN A2 B3 C6 D? E? Disk

14 Redo Example LSNTypeTidPrevLSNData 1SOT1 2UP12A 3 13B 4CP 5SOT3 6UP13C 7SOT2 8UP27D 9EOT16 10UP35B 11UP28A 12EOT211 13UP310E pgNorecLSN A2 B3 C6 D8 E13 Redo UNLESS Page is not in dirtyPgTable If LSN < recLSN If LSN <= pageLSN DirtyPgTable PagepageLSN A2 B3 C6 D? E? Disk

15 Redo Example LSNTypeTidPrevLSNData 1SOT1 2UP12A 3 13B 4CP 5SOT3 6UP13C 7SOT2 8UP27D 9EOT16 10UP35B 11UP28A 12EOT211 13UP310E pgNorecLSN A2 B3 C6 D8 E13 Redo UNLESS Page is not in dirtyPgTable If LSN < recLSN If LSN <= pageLSN DirtyPgTable PagepageLSN A2 B3 C6 D? E? Disk

16 Redo Example LSNTypeTidPrevLSNData 1SOT1 2UP12A 3 13B 4CP 5SOT3 6UP13C 7SOT2 8UP27D 9EOT16 10UP35B 11UP28A 12EOT211 13UP310E pgNorecLSN A2 B3 C6 D8 E13 Redo UNLESS Page is not in dirtyPgTable If LSN < recLSN If LSN <= pageLSN DirtyPgTable PagepageLSN A2 B3 C6 D? E? Disk

17 Redo Example LSNTypeTidPrevLSNData 1SOT1 2UP12A 3 13B 4CP 5SOT3 6UP13C 7SOT2 8UP27D 9EOT16 10UP35B 11UP28A 12EOT211 13UP310E pgNorecLSN A2 B3 C6 D8 E13 Redo UNLESS Page is not in dirtyPgTable If LSN < recLSN If LSN <= pageLSN DirtyPgTable PagepageLSN A2 B3 C6 D? E? Disk

18 Redo Example LSNTypeTidPrevLSNData 1SOT1 2UP12A 3 13B 4CP 5SOT3 6UP13C 7SOT2 8UP27D 9EOT16 10UP35B 11UP28A 12EOT211 13UP310E pgNorecLSN A2 B3 C6 D8 E13 Redo UNLESS Page is not in dirtyPgTable If LSN < recLSN If LSN <= pageLSN DirtyPgTable PagepageLSN A2 B3 C6 D? E? Disk

19 Redo Example LSNTypeTidPrevLSNData 1SOT1 2UP12A 3 13B 4CP 5SOT3 6UP13C 7SOT2 8UP27D 9EOT16 10UP35B 11UP28A 12EOT211 13UP310E pgNorecLSN A2 B3 C6 D8 E13 Redo UNLESS Page is not in dirtyPgTable If LSN < recLSN If LSN <= pageLSN DirtyPgTable PagepageLSN A2 B3 C6 D? E? Disk Buffer/disk pages same as pre-crash

20 Undo Walk backwards, following prevLSNs to UNDO losers LSNTypeTidPrevLSNData 1SOT1 2UP11A 3 12B 4CP 5SOT3 6UP13C 7SOT2 8UP27D 9EOT16 10UP35B 11UP28A 12EOT211 13UP310E lastLSNTID 133 xactionTable

21 Undo Walk backwards, following prevLSNs to UNDO losers LSNTypeTidPrevLSNData 1SOT1 2UP11A 3 12B 4CP 5SOT3 6UP13C 7SOT2 8UP27D 9EOT16 10UP35B 11UP28A 12EOT211 13UP310E lastLSNTID 133 xactionTable

22 Undo Walk backwards, following prevLSNs to UNDO losers LSNTypeTidPrevLSNData 1SOT1 2UP11A 3 12B 4CP 5SOT3 6UP13C 7SOT2 8UP27D 9EOT16 10UP35B 11UP28A 12EOT211 13UP310E lastLSNTID 133 xactionTable

23 What does UNDO do? Why is it safe to undo an op from middle of log? What if the operation split a B+Tree block?

24 Crash during UNDO phase? –Example: T1 starts T1 deletes tuple, modifies heapfile, B+Tree index DB writes all dirty pages to disk checkpoint crash –Nothing to redo –Undo phase starts to modify heapfile/B+Tree, writes some pages to disk, crash again. –Will the 2 nd recovery work correctly?

25 UNDO with CLR LSNTypeTidPrevLSNData 5SOT3 6UP13C 7SOT2 8UP27D 9EOT16 10UP35B 11UP28A 12EOT211 13UP310E Losers: 3

26 UNDO with CLR LSNTypeTidPrevLSNData 5SOT3 6UP13C 7SOT2 8UP27D 9EOT16 10UP35B 11UP28A 12EOT211 13UP310E

27 UNDO with CLR LSNTypeTidPrevLSNData 5SOT3 6UP13C 7SOT2 8UP27D 9EOT16 10UP35B 11UP28A 12EOT211 13UP310E 14CLR3E

28 UNDO with CLR LSNTypeTidPrevLSNData 5SOT3 6UP13C 7SOT2 8UP27D 9EOT16 10UP35B 11UP28A 12EOT211 13UP310E 14CLR310E

29 UNDO with CLR LSNTypeTidPrevLSNData 5SOT3 6UP13C 7SOT2 8UP27D 9EOT16 10UP35B 11UP28A 12EOT211 13UP310E 14CLR310E 15CLR35B

30 UNDO with CLR LSNTypeTidPrevLSNData 5SOT3 6UP13C 7SOT2 8UP27D 9EOT16 10UP35B 11UP28A 12EOT211 13UP310E 14CLR310E 15CLR35B 16EOT3-

31 REDO with CLR REDO CLRs on crash recovery –Just like redo of ordinary update –CLR is the physical redo version of the logical undo –Each CLR has an entire undo’s worth of redo info Thus redo w/ CLRs yields action consistency –After processing CLR, update lastLSN field in xactionTable to point to prevLSN of CLR Allows UNDO to start from the right place


Download ppt "Logging and ARIES. ARIES Example LSNTypeTidPrevLSNData 1SOT1 2UP11A 3 12B 4CP 5SOT3 6UP13C 7SOT2 8UP27D 9EOT16 10UP35B 11UP28A 12EOT211 13UP310E 1 2 3."

Similar presentations


Ads by Google