| Lesson 8 | Redo Logs |
| Objective | Explain how Oracle redo logs enable reliable crash recovery and near real-time recovery. |
Every change you make to database blocks is first recorded as redo. Oracle implements write-ahead logging (WAL): before modified blocks are written to datafiles, the change description (redo) is flushed to the online redo logs. WAL guarantees that, after a crash, Oracle can replay committed work even if dirty buffers never reached the datafiles.
UPDATE that changes the row.
COMMIT, a crash would discard the uncommitted change—this is correct behavior.
COMMIT.
Online redo logs are organized into groups; each group may have multiple members (multiplexed copies on different disks). Oracle writes to one group at a time. When a group fills, a log switch occurs and the sequence number increments.
Tip: Multiplex each group (≥2 members on different devices) to guard against single-file loss.
Current group, size, members, and status:
SELECT l.group#, l.sequence#, l.bytes/1024/1024 AS size_mb,
l.members, l.archived, l.status
FROM v$log l
ORDER BY l.group#;
SELECT lf.group#, lf.member
FROM v$logfile lf
ORDER BY lf.group#, lf.member;
Recent switches (useful for sizing and workload patterns):
SELECT sequence#, first_time, next_time
FROM v$log_history
ORDER BY first_time DESC FETCH FIRST 20 ROWS ONLY;
Force a log switch and archive (as needed):
ALTER SYSTEM SWITCH LOGFILE;
ALTER SYSTEM ARCHIVE LOG CURRENT;
COMMIT (plus other triggers).