Database Systems | Transactions, Recovery, and Logging Strategies

csce 608 database systems n.w
1 / 70
Embed
Share

Explore the concepts of transactions, system failure recovery, and logging strategies in database systems. Learn about ACID properties, coping with system failures, and various logging techniques like Undo-logging, Redo-logging, and Undo/Redo-logging to ensure data consistency and durability.

  • Database Systems
  • Transactions
  • Recovery
  • Logging Strategies
  • ACID Properties

Uploaded on | 1 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.

E N D

Presentation Transcript


  1. CSCE-608 Database Systems Spring 2024 Instructor: Jianer Chen Office: PETR 428 Phone: 845-4259 Email: chen@cse.tamu.edu Notes 35: Undo-logging

  2. lock table DDL complier concurrency control file logging & recovery manager User-1 DDL User-2 transaction manager User-3 index/file manager buffer manager query execution engine DML User-n DML complier main memory buffers secondary storage (disks) DBMS

  3. Tranactions What is a transaction? A sequence of actions that we want to be done as a single logic step What is a logic step (what do we want a transaction to be)? ACID: Atomicity: either all steps of a transaction happen, or none happen Consistency: a transaction transforms a consistent DB into a consistent DB Isolation: execution of a transaction is isolated from that of other transactions Durability: if a transaction commits, its effects persist.

  4. We will be focused on: How to prevent/fix constraint violations due to system failures How do we recover from system failures? due to concurrent executed transactions due to both

  5. System Failure Recovery What we want to recover? Undesired changes made by transactions How can a transaction make undesired changes? Partial changes made by an incomplete transaction whose execution is interrupted because of system failure.

  6. Coping with System Failures Therefore, the logging strategy must be carefully designed to ensure Atomicity and Durability. If you are going to be in the logging business, one of the things that you have to do is to learn about heavy equipment. Robert VanNatta, Logging History of Columbia County We will study three logging strategies: Undo-logging Redo-logging Undo/Redo-logging

  7. Coping with System Failures Therefore, the logging strategy must be carefully designed to ensure Atomicity and Durability. If you are going to be in the logging business, one of the things that you have to do is to learn about heavy equipment. Robert VanNatta, Logging History of Columbia County We will study three logging strategies: Undo-logging Redo-logging Undo/Redo-logging

  8. Undo-Logging The format of the Undo-log: <T, start> <T, A, aold> <T, B, bold> <T, commit> (or <T, abort>) transaction T starts transaction T wrote on A/B, and A/B had an old value aold/bold transaction T commits/abort

  9. Undo-Logging The format of the Undo-log: <T, start> <T, A, aold> <T, B, bold> <T, commit> (or <T, abort>) transaction T starts transaction T wrote on A/B, and A/B had an old value aold/bold transaction T commits/abort Main idea of Undo-logging: When log record <T, commit> reaches disk, all changes made by T have reached disk.

  10. Undo-Logging Main idea of Undo-logging: When <T, commit> reaches disk, all changes made by T have reached disk. <T, start> Undo-logging rules: U1. The log record <T, V, aold> reaches disk before the change of V reaches disk; U2. The log record <T, commit> reaches disk after all changes made by T reach disk. The order in which the values reach disk <T,V1, a1> New V1 <T,V2, a2> <T,V3, a3> New V3 <T,V4, a4> New V4 New V2 <T, commit>

  11. Undo-Logging Undo-logging rules: U1. The log record <T, V, aold> reaches disk before the change of V reaches disk; U2. The log record <T, commit> reaches disk after all changes made by T reach disk. Algorithms for undo-logging Log recording 1. When T writes on A, add a log-record <T, A, aold> (in memory-log); 2. Before output(A), make sure the memory-log is flushed to disk-log at least once; 3. Add log-record <T, commit> to memory-log only when all output(A) related to T are done.

  12. Undo-Logging Undo-logging rules: U1. The log record <T, V, aold> reaches disk before the change of V reaches disk; U2. The log record <T, commit> reaches disk after all changes made by T reach disk. Algorithms for undo-logging Log recording 1. When T writes on A, add a log-record <T, A, aold> (in memory-log); 2. Before output(A), make sure the memory-log is flushed to disk-log at least once; 3. Add log-record <T, commit> to memory-log only when all output(A) related to T are done.

  13. Undo-Logging Undo-logging rules: U1. The log record <T, V, aold> reaches disk before the change of V reaches disk; U2. The log record <T, commit> reaches disk after all changes made by T reach disk. Algorithms for undo-logging Log recording 1. When T writes on A, add a log-record <T, A, aold> (in memory-log); 2. Before output(A), make sure the memory-log is flushed to disk-log at least once; 3. Add log-record <T, commit> to memory-log only when all output(A) related to T are done.

  14. Undo-Logging Undo-logging rules: U1. The log record <T, V, aold> reaches disk before the change of V reaches disk; U2. The log record <T, commit> reaches disk after all changes made by T reach disk. Algorithms for undo-logging Log recording 1. When T writes on A, add a log-record <T, A, aold> (in memory-log); 2. Before output(A), make sure the memory-log is flushed to disk-log at least once; 3. Add log-record <T, commit> to memory-log only when all output(A) related to T are done. System recovery with disk-log 1. Scan the disk-log backwards; 2. Ignore T if see <T, commit>; 3. For each T with no <T, commit> For each log-record <T, A, aold> Undo the action by restoring the value of A back to aold; Add <T, abort> to disk-log.

  15. Undo-Logging Undo-logging rules: U1. The log record <T, V, aold> reaches disk before the change of V reaches disk; U2. The log record <T, commit> reaches disk after all changes made by T reach disk. Algorithms for undo-logging Log recording 1. When T writes on A, add a log-record <T, A, aold> (in memory-log); 2. Before output(A), make sure the memory-log is flushed to disk-log at least once; 3. Add log-record <T, commit> to memory-log only when all output(A) related to T are done. System recovery with disk-log 1. Scan the disk-log backwards; 2. Ignore T if see <T, commit>; 3. For each T with no <T, commit> For each log-record <T, A, aold> Undo the action by restoring the value of A back to aold; Add <T, abort> to disk-log.

  16. Undo-Logging Undo-logging rules: U1. The log record <T, V, aold> reaches disk before the change of V reaches disk; U2. The log record <T, commit> reaches disk after all changes made by T reach disk. Algorithms for undo-logging Log recording 1. When T writes on A, add a log-record <T, A, aold> (in memory-log); 2. Before output(A), make sure the memory-log is flushed to disk-log at least once; 3. Add log-record <T, commit> to memory-log only when all output(A) related to T are done. System recovery with disk-log 1. Scan the disk-log backwards; 2. Ignore T if see <T, commit>; 3. For each T with no <T, commit> For each log-record <T, A, aold> Undo the action by restoring the value of A back to aold; Add <T, abort> to disk-log.

  17. Undo-Logging Undo-logging rules: U1. The log record <T, V, aold> reaches disk before the change of V reaches disk; U2. The log record <T, commit> reaches disk after all changes made by T reach disk. Algorithms for undo-logging Log recording 1. When T writes on A, add a log-record <T, A, aold> (in memory-log); 2. Before output(A), make sure the memory-log is flushed to disk-log at least once; 3. Add log-record <T, commit> to memory-log only when all output(A) related to T are done. System recovery with disk-log 1. Scan the disk-log backwards; 2. Ignore T if see <T, commit>; 3. For each T with no <T, commit> For each log-record <T, A, aold> Undo the action by restoring the value of A back to aold; Add <T, abort> to disk-log.

  18. Log recording 1. When T writes on A, add a log-record <T, A, aold> (in memory-log); 2. Before output(A), make sure the memory-log is flushed to disk-log at least once; 3. Add log-record <T, commit> to memory-log only when all output(A) related to T are done. Undo-logging: Example T1: A A 3 B B 3 read (A,t); t t 3; write (A,t); read (B,t); t t 3; write (B,t); output (A); output (B); CPU C=30 B=10 A=10 memory disk 18 18

  19. Log recording 1. When T writes on A, add a log-record <T, A, aold> (in memory-log); 2. Before output(A), make sure the memory-log is flushed to disk-log at least once; 3. Add log-record <T, commit> to memory-log only when all output(A) related to T are done. Undo-logging: log recording T: A A 3 B B 3 add-log: <T, start> read (A,t); t t 3; write (A,t); add-log: <T, A, 10> flush-log output (A); read (B,t); t t 3; write (B,t); add-log: <T, B, 10> flush-log output (B); add-log: <T, commit> CPU C=30 B=10 A=10 memory disk 19 19

  20. Log recording 1. When T writes on A, add a log-record <T, A, aold> (in memory-log); 2. Before output(A), make sure the memory-log is flushed to disk-log at least once; 3. Add log-record <T, commit> to memory-log only when all output(A) related to T are done. Undo-logging: log recording T: A A 3 B B 3 add-log: <T, start> read (A,t); t t 3; write (A,t); add-log: <T, A, 10> read (B,t); t t 3; write (B,t); add-log: <T, B, 10> flush-log output (A); output (B); add-log: <T, commit> CPU C=30 B=10 A=10 memory disk 20 20

  21. Log recording 1. When T writes on A, add a log-record <T, A, aold> (in memory-log); 2. Before output(A), make sure the memory-log is flushed to disk-log at least once; 3. Add log-record <T, commit> to memory-log only when all output(A) related to T are done. Undo-logging: log recording T: A A 3 B B 3 add-log: <T, start> read (A,t); t t 3; write (A,t); add-log: <T, A, 10> read (B,t); t t 3; write (B,t); add-log: <T, B, 10> flush-log output (A); output (B); add-log: <T, commit> CPU C=30 log B=10 A=10 <T, start> memory disk 21 21

  22. Log recording 1. When T writes on A, add a log-record <T, A, aold> (in memory-log); 2. Before output(A), make sure the memory-log is flushed to disk-log at least once; 3. Add log-record <T, commit> to memory-log only when all output(A) related to T are done. Undo-logging: log recording T: A A 3 B B 3 add-log: <T, start> read (A,t); t t 3; write (A,t); add-log: <T, A, 10> read (B,t); t t 3; write (B,t); add-log: <T, B, 10> flush-log output (A); output (B); add-log: <T, commit> CPU C=30 log B=10 A=10 A=30 <T, start> <T, A, 10> memory disk 22 22

  23. Log recording 1. When T writes on A, add a log-record <T, A, aold> (in memory-log); 2. Before output(A), make sure the memory-log is flushed to disk-log at least once; 3. Add log-record <T, commit> to memory-log only when all output(A) related to T are done. Undo-logging: log recording T: A A 3 B B 3 add-log: <T, start> read (A,t); t t 3; write (A,t); add-log: <T, A, 10> read (B,t); t t 3; write (B,t); add-log: <T, B, 10> flush-log output (A); output (B); add-log: <T, commit> CPU C=30 log B=10 A=10 A=30 <T, start> <T, A, 10> <T, B, 10> B=30 memory disk 23 23

  24. Log recording 1. When T writes on A, add a log-record <T, A, aold> (in memory-log); 2. Before output(A), make sure the memory-log is flushed to disk-log at least once; 3. Add log-record <T, commit> to memory-log only when all output(A) related to T are done. Undo-logging: log recording T: A A 3 B B 3 add-log: <T, start> read (A,t); t t 3; write (A,t); add-log: <T, A, 10> read (B,t); t t 3; write (B,t); add-log: <T, B, 10> flush-log output (A); output (B); add-log: <T, commit> CPU C=30 log B=10 A=10 A=30 <T, start> <T, A, 10> <T, B, 10> <T, B, 10> <T, start> <T, A, 10> B=30 <T, start> <T, A, 10> <T, B, 10> memory disk 24 24

  25. Log recording 1. When T writes on A, add a log-record <T, A, aold> (in memory-log); 2. Before output(A), make sure the memory-log is flushed to disk-log at least once; 3. Add log-record <T, commit> to memory-log only when all output(A) related to T are done. Undo-logging: log recording T: A A 3 B B 3 add-log: <T, start> read (A,t); t t 3; write (A,t); add-log: <T, A, 10> read (B,t); t t 3; write (B,t); add-log: <T, B, 10> flush-log output (A); output (B); add-log: <T, commit> CPU C=30 log B=10 A=10 A=30 A=30 <T, start> <T, A, 10> <T, B, 10> B=30 B=30 <T, start> <T, A, 10> <T, B, 10> memory disk 25 25

  26. Log recording 1. When T writes on A, add a log-record <T, A, aold> (in memory-log); 2. Before output(A), make sure the memory-log is flushed to disk-log at least once; 3. Add log-record <T, commit> to memory-log only when all output(A) related to T are done. Undo-logging: log recording T: A A 3 B B 3 add-log: <T, start> read (A,t); t t 3; write (A,t); add-log: <T, A, 10> read (B,t); t t 3; write (B,t); add-log: <T, B, 10> flush-log output (A); output (B); add-log: <T, commit> CPU C=30 log B=30 A=30 A=30 <T, start> <T, A, 10> <T, B, 10> <T, start> <T, A, 10> <T, B, 10> <T, commit> <T, commit> B=30 <T, start> <T, A, 10> <T, B, 10> <T, A, 10> <T, B, 10> <T, start> memory disk 26 26

  27. Undo-logging: Failure Recovery CPU C=30 B=10 A=10 memory disk 27 27

  28. System recovery with disk-log 1. Scan the disk-log backwards; 2. Ignore T if see <T, commit>; 3. For each T with no <T, commit> For each log-record <T, A, aold> Undo the action by restoring the value of A back to aold; Add <T, abort> to disk-log. Undo-logging: Failure Recovery T: A A 3 B B 3 add-log: <T, start> read (A,t); t t 3; write (A,t); add-log: <T, A, 10> read (B,t); t t 3; write (B,t); add-log: <T, B, 10> flush-log output (A); output (B); add-log: <T, commit> CPU C=30 B=10 A=10 memory disk 28 28

  29. System recovery with disk-log 1. Scan the disk-log backwards; 2. Ignore T if see <T, commit>; 3. For each T with no <T, commit> For each log-record <T, A, aold> Undo the action by restoring the value of A back to aold; Add <T, abort> to disk-log. Undo-logging: Failure Recovery T: A A 3 B B 3 add-log: <T, start> read (A,t); t t 3; write (A,t); add-log: <T, A, 10> read (B,t); t t 3; write (B,t); add-log: <T, B, 10> flush-log output (A); output (B); add-log: <T, commit> CPU C=30 B=10 A=10 crash occurs after this point, memory disk 29 29

  30. System recovery with disk-log 1. Scan the disk-log backwards; 2. Ignore T if see <T, commit>; 3. For each T with no <T, commit> For each log-record <T, A, aold> Undo the action by restoring the value of A back to aold; Add <T, abort> to disk-log. Undo-logging: Failure Recovery T: A A 3 B B 3 add-log: <T, start> read (A,t); t t 3; write (A,t); add-log: <T, A, 10> read (B,t); t t 3; write (B,t); add-log: <T, B, 10> flush-log output (A); output (B); add-log: <T, commit> CPU C=30 log B=30 A=30 A=30 <T, start> <T, A, 10> <T, B, 10> <T, commit> B=30 <T, start> <T, A, 10> <T, B, 10> <T, commit> crash occurs after this point, memory disk 30 30

  31. System recovery with disk-log 1. Scan the disk-log backwards; 2. Ignore T if see <T, commit>; 3. For each T with no <T, commit> For each log-record <T, A, aold> Undo the action by restoring the value of A back to aold; Add <T, abort> to disk-log. Undo-logging: Failure Recovery T: A A 3 B B 3 add-log: <T, start> read (A,t); t t 3; write (A,t); add-log: <T, A, 10> read (B,t); t t 3; write (B,t); add-log: <T, B, 10> flush-log output (A); output (B); add-log: <T, commit> CPU C=30 B=30 A=30 <T, start> <T, A, 10> <T, B, 10> <T, commit> crash occurs after this point, memory disk 31 31

  32. System recovery with disk-log 1. Scan the disk-log backwards; 2. Ignore T if see <T, commit>; 3. For each T with no <T, commit> For each log-record <T, A, aold> Undo the action by restoring the value of A back to aold; Add <T, abort> to disk-log. Undo-logging: Failure Recovery T: A A 3 B B 3 add-log: <T, start> read (A,t); t t 3; write (A,t); add-log: <T, A, 10> read (B,t); t t 3; write (B,t); add-log: <T, B, 10> flush-log output (A); output (B); add-log: <T, commit> CPU C=30 B=30 A=30 <T, start> <T, A, 10> <T, B, 10> <T, commit> crash occurs after this point, memory disk 32 32

  33. System recovery with disk-log 1. Scan the disk-log backwards; 2. Ignore T if see <T, commit>; 3. For each T with no <T, commit> For each log-record <T, A, aold> Undo the action by restoring the value of A back to aold; Add <T, abort> to disk-log. Undo-logging: Failure Recovery T: A A 3 B B 3 add-log: <T, start> read (A,t); t t 3; write (A,t); add-log: <T, A, 10> read (B,t); t t 3; write (B,t); add-log: <T, B, 10> flush-log output (A); output (B); add-log: <T, commit> CPU C=30 log B=30 A=30 A=30 <T, start> <T, A, 10> <T, B, 10> B=30 <T, start> <T, A, 10> <T, B, 10> memory crash occurs at this point disk 33 33

  34. System recovery with disk-log 1. Scan the disk-log backwards; 2. Ignore T if see <T, commit>; 3. For each T with no <T, commit> For each log-record <T, A, aold> Undo the action by restoring the value of A back to aold; Add <T, abort> to disk-log. Undo-logging: Failure Recovery T: A A 3 B B 3 add-log: <T, start> read (A,t); t t 3; write (A,t); add-log: <T, A, 10> read (B,t); t t 3; write (B,t); add-log: <T, B, 10> flush-log output (A); output (B); add-log: <T, commit> CPU C=30 B=30 A=30 <T, start> <T, A, 10> <T, B, 10> memory crash occurs at this point disk 34 34

  35. System recovery with disk-log 1. Scan the disk-log backwards; 2. Ignore T if see <T, commit>; 3. For each T with no <T, commit> For each log-record <T, A, aold> Undo the action by restoring the value of A back to aold; Add <T, abort> to disk-log. Undo-logging: Failure Recovery T: A A 3 B B 3 add-log: <T, start> read (A,t); t t 3; write (A,t); add-log: <T, A, 10> read (B,t); t t 3; write (B,t); add-log: <T, B, 10> flush-log output (A); output (B); add-log: <T, commit> CPU C=30 B=10 A=10 <T, start> <T, A, 10> <T, B, 10> <T, abort> memory crash occurs at this point disk 35 35

  36. System recovery with disk-log 1. Scan the disk-log backwards; 2. Ignore T if see <T, commit>; 3. For each T with no <T, commit> For each log-record <T, A, aold> Undo the action by restoring the value of A back to aold; Add <T, abort> to disk-log. Undo-logging: Failure Recovery T: A A 3 B B 3 add-log: <T, start> read (A,t); t t 3; write (A,t); add-log: <T, A, 10> read (B,t); t t 3; write (B,t); add-log: <T, B, 10> flush-log output (A); output (B); add-log: <T, commit> CPU C=30 log B=10 A=30 A=30 <T, start> <T, A, 10> <T, B, 10> B=30 <T, start> <T, A, 10> <T, B, 10> crash occurs at this point memory disk 36 36

  37. System recovery with disk-log 1. Scan the disk-log backwards; 2. Ignore T if see <T, commit>; 3. For each T with no <T, commit> For each log-record <T, A, aold> Undo the action by restoring the value of A back to aold; Add <T, abort> to disk-log. Undo-logging: Failure Recovery T: A A 3 B B 3 add-log: <T, start> read (A,t); t t 3; write (A,t); add-log: <T, A, 10> read (B,t); t t 3; write (B,t); add-log: <T, B, 10> flush-log output (A); output (B); add-log: <T, commit> CPU C=30 log B=10 A=10 A=30 <T, start> <T, A, 10> <T, B, 10> B=30 <T, start> <T, A, 10> <T, B, 10> <T, abort> crash occurs at this point memory disk 37 37

  38. System recovery with disk-log 1. Scan the disk-log backwards; 2. Ignore T if see <T, commit>; 3. For each T with no <T, commit> For each log-record <T, A, aold> Undo the action by restoring the value of A back to aold; Add <T, abort> to disk-log. Undo-logging: Failure Recovery T: A A 3 B B 3 add-log: <T, start> read (A,t); t t 3; write (A,t); add-log: <T, A, 10> read (B,t); t t 3; write (B,t); add-log: <T, B, 10> flush-log output (A); output (B); add-log: <T, commit> CPU C=30 log B=10 A=10 A=30 <T, start> <T, A, 10> <T, B, 10> B=30 <T, start> <T, A, 10> <T, B, 10> crash occurs at this point memory disk 38 38

  39. System recovery with disk-log 1. Scan the disk-log backwards; 2. Ignore T if see <T, commit>; 3. For each T with no <T, commit> For each log-record <T, A, aold> Undo the action by restoring the value of A back to aold; Add <T, abort> to disk-log. Undo-logging: Failure Recovery T: A A 3 B B 3 add-log: <T, start> read (A,t); t t 3; write (A,t); add-log: <T, A, 10> read (B,t); t t 3; write (B,t); add-log: <T, B, 10> flush-log output (A); output (B); add-log: <T, commit> CPU C=30 log B=10 A=10 A=30 <T, start> <T, A, 10> <T, B, 10> B=30 <T, start> <T, A, 10> <T, B, 10> <T, abort> crash occurs at this point memory disk 39 39

  40. System recovery with disk-log 1. Scan the disk-log backwards; 2. Ignore T if see <T, commit>; 3. For each T with no <T, commit> For each log-record <T, A, aold> Undo the action by restoring the value of A back to aold; Add <T, abort> to disk-log. Undo-logging: Failure Recovery T: A A 3 B B 3 add-log: <T, start> read (A,t); t t 3; write (A,t); add-log: <T, A, 10> read (B,t); t t 3; write (B,t); add-log: <T, B, 10> flush-log output (A); output (B); add-log: <T, commit> CPU C=30 log B=10 A=10 A=30 <T, start> <T, A, 10> <T, B, 10> B=30 crash occurs before this point memory disk 40 40

  41. System recovery with disk-log 1. Scan the disk-log backwards; 2. Ignore T if see <T, commit>; 3. For each T with no <T, commit> For each log-record <T, A, aold> Undo the action by restoring the value of A back to aold; Add <T, abort> to disk-log. Undo-logging: Failure Recovery T: A A 3 B B 3 add-log: <T, start> read (A,t); t t 3; write (A,t); add-log: <T, A, 10> read (B,t); t t 3; write (B,t); add-log: <T, B, 10> flush-log output (A); output (B); add-log: <T, commit> CPU C=30 log B=10 A=10 A=30 <T, start> <T, A, 10> <T, B, 10> B=30 crash occurs before this point <T, start> <T, A, 10> memory disk 41 41

  42. System recovery with disk-log 1. Scan the disk-log backwards; 2. Ignore T if see <T, commit>; 3. For each T with no <T, commit> For each log-record <T, A, aold> Undo the action by restoring the value of A back to aold; Add <T, abort> to disk-log. Undo-logging: Failure Recovery T: A A 3 B B 3 add-log: <T, start> read (A,t); t t 3; write (A,t); add-log: <T, A, 10> read (B,t); t t 3; write (B,t); add-log: <T, B, 10> flush-log output (A); output (B); add-log: <T, commit> CPU C=30 B=10 A=10 crash occurs before this point <T, start> <T, A, 10> memory disk 42 42

  43. System recovery with disk-log 1. Scan the disk-log backwards; 2. Ignore T if see <T, commit>; 3. For each T with no <T, commit> For each log-record <T, A, aold> Undo the action by restoring the value of A back to aold; Add <T, abort> to disk-log. Undo-logging: Failure Recovery T: A A 3 B B 3 add-log: <T, start> read (A,t); t t 3; write (A,t); add-log: <T, A, 10> read (B,t); t t 3; write (B,t); add-log: <T, B, 10> flush-log output (A); output (B); add-log: <T, commit> CPU C=30 B=10 A=10 crash occurs before this point <T, start> <T, A, 10> memory disk 43 43

  44. System recovery with disk-log 1. Scan the disk-log backwards; 2. Ignore T if see <T, commit>; 3. For each T with no <T, commit> For each log-record <T, A, aold> Undo the action by restoring the value of A back to aold; Add <T, abort> to disk-log. Undo-logging: Failure Recovery T: A A 3 B B 3 add-log: <T, start> read (A,t); t t 3; write (A,t); add-log: <T, A, 10> read (B,t); t t 3; write (B,t); add-log: <T, B, 10> flush-log output (A); output (B); add-log: <T, commit> CPU C=30 B=10 A=10 crash occurs before this point <T, start> <T, A, 10> <T, abort> memory disk 44 44

  45. System recovery with disk-log 1. Scan the disk-log backwards; 2. Ignore T if see <T, commit>; 3. For each T with no <T, commit> For each log-record <T, A, aold> Undo the action by restoring the value of A back to aold; Add <T, abort> to disk-log. Undo-logging: Failure Recovery Remarks: A. To execute the recovery algorithm, we need to 45 45

  46. System recovery with disk-log 1. Scan the disk-log backwards; 2. Ignore T if see <T, commit>; 3. For each T with no <T, commit> For each log-record <T, A, aold> Undo the action by restoring the value of A back to aold; Add <T, abort> to disk-log. Undo-logging: Failure Recovery Remarks: A. To execute the recovery algorithm, we need to A.1 Read the disk-log into the main memory; 46 46

  47. System recovery with disk-log 1. Scan the disk-log backwards; 2. Ignore T if see <T, commit>; 3. For each T with no <T, commit> For each log-record <T, A, aold> Undo the action by restoring the value of A back to aold; Add <T, abort> to disk-log. Undo-logging: Failure Recovery Remarks: A. To execute the recovery algorithm, we need to A.1 Read the disk-log into the main memory; A.2 FOR each <T, A, aold> in step 3 DO write(A, aold); output(A); 47 47

  48. System recovery with disk-log 1. Scan the disk-log backwards; 2. Ignore T if see <T, commit>; 3. For each T with no <T, commit> For each log-record <T, A, aold> Undo the action by restoring the value of A back to aold; Add <T, abort> to disk-log. Undo-logging: Failure Recovery Remarks: A. To execute the recovery algorithm, we need to A.1 Read the disk-log into the main memory; A.2 FOR each <T, A, aold> in step 3 DO write(A, aold); output(A); B. What if the system crashes again during Undo? 48 48

  49. System recovery with disk-log 1. Scan the disk-log backwards; 2. Ignore T if see <T, commit>; 3. For each T with no <T, commit> For each log-record <T, A, aold> Undo the action by restoring the value of A back to aold; Add <T, abort> to disk-log. Undo-logging: Failure Recovery Remarks: A. To execute the recovery algorithm, we need to A.1 Read the disk-log into the main memory; A.2 FOR each <T, A, aold> in step 3 DO write(A, aold); output(A); B. What if the system crashes again during Undo? * The disk-log remains; 49 49

  50. System recovery with disk-log 1. Scan the disk-log backwards; 2. Ignore T if see <T, commit>; 3. For each T with no <T, commit> For each log-record <T, A, aold> Undo the action by restoring the value of A back to aold; Add <T, abort> to disk-log. Undo-logging: Failure Recovery Remarks: A. To execute the recovery algorithm, we need to A.1 Read the disk-log into the main memory; A.2 FOR each <T, A, aold> in step 3 DO write(A, aold); output(A); B. What if the system crashes again during Undo? * The disk-log remains; * We can simply repeat steps A.1 and A.2; 50 50

Related


More Related Content