Recovery Flashcards
What is a roll back?
Any writes to disk undone, happens on error.
Possible types of failure
- Logical error: Some form of internal error.
- System error: Deadlock, bad scheduler etc.
- System Crash: Power Failure, HW malfunction etc.
- Disk failure
How does atomicity affect recovery?
Modifying the database without ensuring that the transaction will commit may leave the database in an inconsistent state.
How do we ensure atomicity despite failures?
We output information describing the modifications to stable storage before modifying the database.
What two approaches can be used to store modification to the database in memory?
- Log-based recovery
- Shadow paging
How does log based recovery work?
What two approaches can be used using logs?
- Deferred database modification
- Immediate database modification
What is deferred database modification?
- All modifications recorded in log, but writes deferred until after partial commit
- Write operation doesn’t include old value.
How does deferred DB modification recover from a crash?
- Transaction only needs to be done if both Ti start> and are in the log.
- Redo Ti sets value of all data items updated by the transaction to new values.
What is immediate database modification?
- Allows updates of uncommitted transactions
- Log record wrote to before DB
How does immediate DB modification recover from failure?
- Redo Ti sets the value of all data items to their new values, going forward from log Ti
- Undo restores the value of all data update by Ti to their old values, going backward from the last log record for Ti
What happens when recovering from failure using immediate database modification?
Ti needs redone if start and commit in log.
Ti needs undone if start in log with no commit.
Redo done first, undo list populated and done after.
How do checkpoints work?
Periodic checkpoints flush records to disk and timestamps. Completed transactions are then removed from the log.
How are checkpoints used during recovery?
Only consider log records that hadn’t been completed by time of last checkpoint.
Why is log record buffering used?
Output to stable storage in blocks using log force/buffer is full. Reduces I/O cost.