Presentation is loading. Please wait.

Presentation is loading. Please wait.

Recovery. T1 Read(A) A:=A-500; Write(A) Read(B) B:=B+500 Write(B) commit Example: BA 1000 ?? fail.

Similar presentations


Presentation on theme: "Recovery. T1 Read(A) A:=A-500; Write(A) Read(B) B:=B+500 Write(B) commit Example: BA 1000 ?? fail."— Presentation transcript:

1 Recovery

2 T1 Read(A) A:=A-500; Write(A) Read(B) B:=B+500 Write(B) commit Example: BA 1000 ?? fail

3 Two approaches for modifying the database when using logs Deferred database modification Immediate database modification

4 Deferred database modification

5 Log zyx 000 4010050 Log zyx 000 000

6 Immediate database modification

7 Log zyx 000 4010050

8 How is the process Recovery do? Rollback Recovery procedure has two operations instead of one: Undo redo

9 Log fail Redo : Commit listActivity list ZYX 302010

10 Log fail Commit listActivity list T1T2 T3 redo( T 1 ) and redo( T 3 ) must be performed since is present Redo : ZYX 302010 5020100

11 Undo / Redo : Log fail Commit listActivity list ZYX 302010

12 Undo / Redo : Log fail Commit listActivity list T1T2 T3 ZYX 302010 50200 20100 undo ( T 2 ) and redo ( T 1 ) and redo ( T 3 ): Y is restored to 20, and then X and Z are set to 100 and 50 respectively.

13 We assume that the original item values, shown in the first line, are A = 10, B = 30, C = 20. Which transactions will rollback if transaction T3 has not reached its conclusion and must be rolled back? ● What is the final value for each item?

14 ABC 103020 [start_transction,T3] [read_item,T3,A] [write_item,T3,A,10,5] 5 [start_transction,T1] [read_item,T1,A] [start_transction,T2] [read_item,T2,B] [read_item,T1,B] [write_item,T1,B,30,22] 22 [write_item,T2,B,22,6] 6 [read_item,T1,C] [write_item,T1,C,20,100] 100 [read_item,T2,A] [write_item,T2,A, 5,2] 2 CBA 100610  T2 must be roll back because T3 has not reached

15 Checkpoints

16 Example of Checkpoints  T 1 can be ignored (updates already output to disk due to checkpoint)  T 2 and T 3 redone.  T 4 undone TcTc TfTf T1T1 T2T2 T3T3 T4T4 checkpoint system failure

17 Consider a database with data items {A, B, C, D}. The system uses an undo/redo scheme and has the following logs. Note that an entry means transaction T changes the value of X from old to new. We consider recovery using this undo/redo log. 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. System failed Example:

18 1. List all possible values of A, B, C and D. That is, what are the possible data values on the disk at the point of failure (after action 21)? A= 20 or 21, B=11, C = 30 or 31 or 32 or 33, D = 50, 51, 52 2. During recovery, what are the transactions that need to be undone? T1, T6. 3. During recovery, what are the transactions that need to be redone? T3, T4, T5 4. During recovery, what are the transactions that need to be ignored ? T2 5. What are the values of A, B, C, D after recovery? Explain why ? A = 20 B = 41 C = 31 D = 52 A= 20 because T1 is undo. B= 41 because T4 is redone. C= 31 because both T1 and T6 are undone and T3 is redone. D = 52 because T5 is redone.


Download ppt "Recovery. T1 Read(A) A:=A-500; Write(A) Read(B) B:=B+500 Write(B) commit Example: BA 1000 ?? fail."

Similar presentations


Ads by Google