hw6 Sols
hw6 Sols
IMPORTANT:
• Upload this PDF with your answers to Gradescope by 11:59pm on Monday Nov 27,
2017.
• Plagiarism: Homework may be discussed with other students, but all homework is to be
completed individually.
• You have to use this PDF for all of your answers.
For your information:
• Graded out of 100 points; 3 questions total
• Rough time estimate: ≈ 1 - 2 hours
Revision : 2017/12/10 13:52
1
15-445/645 (Fall 2017) Homework 6 Page 2 of 7
Figure 1: WAL
(a) [10 points] What are the values of X, Y, and Z in the database stored on disk before the
DBMS recovers the state of the database?
2 X=1, Y=1, Z=1
2 X=1, Y=2, Z=3
2 X=2, Y=3, Z=2
2 X=2, Y=2, Z=3
2 X=3, Y=1, Z=2
2 X=3, Y=4, Z=3
2 X=3, Y=4, Z=4
Not possible to determine
Solution: The checkpoint flushed everything to disk, but then all the data objects were
modified by transactions after the checkpoint.
Since we are using NO-FORCE, any dirty page could be written to disk, so therefore we
don’t know the contents of the database on disk at the crash.
Question 1 continues. . .
15-445/645 (Fall 2017) Homework 6 Page 3 of 7
(b) [5 points] What should be the correct action on T1 when recovering the database from
WAL?
undo all of T1’s changes
2 redo all of T1’s changes
2 do nothing to T1
Solution: T1 never committed. All of its changes should only be undone.
(c) [5 points] What should be the correct action on T2 when recovering the database from
WAL?
2 undo all of T2’s changes
2 redo all of T2’s changes
do nothing to T2
Solution: T2 committed before the checkpont. All of its changes were written to disk.
There is nothing to redo or undo.
(d) [5 points] What should be the correct action on T3 when recovering the database from
WAL?
2 undo all of T3’s changes
redo all of T3’s changes
2 do nothing to T3
Solution: T3 committed after the checkpont, so that means the DBMS has to redo all
of its changes.
(e) [10 points] Assume that the DBMS flushes all dirty pages when the recovery process
finishes. What are the values of X, Y, and Z after the DBMS recovers the state of the
database from the WAL in Figure 1?
2 X=1, Y=1, Z=1
X=1, Y=2, Z=3
2 X=2, Y=3, Z=2
2 X=2, Y=2, Z=3
2 X=3, Y=1, Z=2
2 X=3, Y=4, Z=3
2 X=3, Y=4, Z=4
2 Not possible to determine
Solution: X = 1 (rollback the beforeValue from T1)
Y = 2 (rollback to the afterValue made by T2)
Question 1 continues. . .
15-445/645 (Fall 2017) Homework 6 Page 4 of 7
Homework 6 continues. . .
15-445/645 (Fall 2017) Homework 6 Page 5 of 7
Figure 2: ARIES
(b) After the recovery has ended successfully and assuming that all the dirty pages have been
flushed to disk,
i. [3 points] What will be the value of X on disk?
2 1
2
2 Unknown
Solution: New value of X will be on disk as T1 will be redone
Question 2 continues. . .
15-445/645 (Fall 2017) Homework 6 Page 6 of 7
2 3
4
2 Unknown
Solution: New value of Y will be on disk as T2 will be redone
(c) [15 points] After the recovery has ended, what will be the contents of the log? Specify
the log records after the crash.
Solution: 10: <T2 end>
11: <CLR undo T4 LSN 8>
12: <T4 end ;>
13: <CLR undo T3 LSN 7>
14: <T3 end>
Homework 6 continues. . .
15-445/645 (Fall 2017) Homework 6 Page 7 of 7
(b) [4 points] Under NO-STEAL + FORCE policy, a DBMS will have to undo the changes
of an aborted transaction during recovery.
2 True
False
(c) [4 points] Under the NO-STEAL policy, a DBMS will need to store the whole table in
RAM if a transaction updates all the records of that table.
True
2 False
(d) [4 points] While doing deferred updates with WAL, if we prevent the DBMS from writ-
ing dirty records to disk until the transaction commits, then we do not need to store their
original values.
True
2 False
(e) [4 points] Most production systems use STEAL + NO-FORCE policy as it has the
fastest recovery performance.
2 True
False
(f) [4 points] In ARIES, log records are immediately flushed on the log, as soon as they are
produced.
2 True
False
(g) [4 points] Without checkpoints, the redo phase of ARIES recovery should process the
whole log.
True
2 False
End of Homework 6