Recovery and Logging Flashcards
1
Q
Caching
A
- Recently accessed database pages are cached in memory to reduce disk I/O
2
Q
Recovery
A
- Performed after a crash or non-catastrophic failure
- Need to maintain enough state about transactions to redo or undo them
3
Q
Recovery Steps
A
- Redo changes made by any committed transaction
- Undo changes made by any transaction that didn’t commit
4
Q
Log
A
- Update records summarizing writes
- Records for transaction begins
- Records for transaction commits
- Append-only
5
Q
Write-Ahead Logging (WAL)
A
- Both updated database pages and log records are cached
- All update log records must be forced to disk before the database page
6
Q
Undo-Redo Logging
A
- Update records must include both the old and new values
- At commit, write the commit log record to the in-memory log buffer and force to disk all dirty log records
7
Q
Undo-Redo Backward Pass
A
- For each commit record, add the transaction to a commit list
- For each update by a transaction not on the commit list, undo the update
- Skip updates on the commit list and all begin records
8
Q
Undo-Redo Forward Pass
A
- For each update by a transaction on the commit list, redo the update
- Skip updates by transactions not on the commit list
9
Q
Logical Logging
A
- When a data element is updated, store the LSN of the updated log record with the data element (datum LSN)
- Stores the old LSN of the data element in the log record
10
Q
Logical Logging Backward Pass
A
- Undo an update if the transaction did not commit and datum LSN == record LSN
- If undo, set datum LSN = olsn
11
Q
Logical Logging Forward Pass
A
- Redo an update if the transaction did commit and datum LSN == olsn
- If redo, set datum LSN = record LSN
12
Q
Undo-Only Logging
A
- Force all dirty log records to disk
- Force database pages changed by the transaction to disk
- Write the commit log record
- Force the commit log record to the disk
13
Q
Redo-Only Logging
A
- Write the commit log record
- Force all dirty log records to disk
- Move database pages to disk anytime after this
14
Q
Advantages and Disadvantages of Undo-Only Logging
A
- Smaller logs than undo-redo (+)
- Simple and quick recovery (+)
- Forces log and data to disk at commit (wait for I/O) (-)
15
Q
Advantages and Disadvantages of Redo-Only Logging
A
- Smaller logs than undo-redo (+)
- More complex recovery than undo-only, but less than undo-redo (+/-)
- Must be able to cache all changes until the transaction commits (-)
- Forces only log records to disk at commit (+)