Originally posted in 2015. Updated November 2026 for Oracle Database 19c and 21c.
How Oracle writes to the online redo log
Each database instance writes its redo to its own set of online redo log groups, called a redo thread. A single-instance database has one thread. In Oracle RAC every instance has its own thread, so the instances never compete for the same log files.
Each thread needs at least two redo log groups, so that one group can be written while the previous one is archived (in ARCHIVELOG mode). The log writer process (LGWR) writes to one group at a time, called the CURRENT group. When it fills up, a log switch happens and LGWR moves to the next group in the thread, going round in a circle.
Group status values in V$LOG:
- CURRENT: LGWR is writing to this group now.
- ACTIVE: no longer current, but still needed for instance recovery (or not yet archived).
- INACTIVE: no longer needed for instance recovery and can be reused.
- UNUSED: never written to, such as a newly added group.
What it looks like in a 4-node RAC
Here each of the 4 instances has 2 groups of 100 MB. Notice that every thread has its own CURRENT group and its own sequence numbers:
racdb1> SELECT group#, thread#, sequence#, bytes/1024/1024 AS mb, members, status
FROM v$log ORDER BY thread#, group#;
GROUP# THREAD# SEQUENCE# MB MEMBERS STATUS
---------- ---------- ---------- ---------- ---------- --------
1 1 115 100 1 INACTIVE
2 1 116 100 1 CURRENT
3 2 87 100 1 ACTIVE
4 2 88 100 1 CURRENT
5 3 67 100 1 INACTIVE
6 3 68 100 1 CURRENT
7 4 79 100 1 CURRENT
8 4 78 100 1 INACTIVE
Now switch the log on instance 1 and check again:
racdb1> ALTER SYSTEM SWITCH LOGFILE;
racdb1> SELECT group#, thread#, sequence#, status FROM v$log ORDER BY thread#, group#;
GROUP# THREAD# SEQUENCE# STATUS
---------- ---------- ---------- --------
1 1 117 CURRENT <-- thread 1 moved to group 1
2 1 116 ACTIVE <-- previous log, still needed
3 2 87 ACTIVE
4 2 88 CURRENT <-- threads 2-4 unchanged
5 3 67 INACTIVE
6 3 68 CURRENT
7 4 79 CURRENT
8 4 78 INACTIVE
ALTER SYSTEM SWITCH LOGFILE switches only the thread of the instance you are connected to. Threads 2, 3 and 4 did not change; each moves on by itself when its own instance fills its current log. To switch and archive every thread at once, for example before a backup or when testing Data Guard, use:
ALTER SYSTEM ARCHIVE LOG CURRENT;
Checking redo across all instances (19c and 21c)
-- Groups and members for every thread SELECT l.thread#, l.group#, l.sequence#, l.bytes/1024/1024 AS mb, l.status, f.member FROM v$log l JOIN v$logfile f ON f.group# = l.group# ORDER BY l.thread#, l.group#; -- Log switches per hour, per thread, for the last 2 days SELECT TRUNC(first_time,'HH24') AS hour, thread#, COUNT(*) AS switches FROM v$log_history WHERE first_time > SYSDATE - 2 GROUP BY TRUNC(first_time,'HH24'), thread# ORDER BY 1, 2;
19c and 21c notes
- Multitenant: redo belongs to the CDB. In a container database, all PDBs share the CDB's redo threads. A PDB has no redo logs of its own, so add, resize or drop redo log groups while connected to CDB$ROOT. From 21c onward, every database is a CDB, because non-CDB architecture is desupported.
- Scalable LGWR. Since 12c, LGWR can hand work to helper processes (LG00, LG01 and so on) on busy systems. You will see them in
ps -efandV$PROCESS; they are normal. - Watch commit waits. High
log file syncorlog file parallel writewait times in AWR mean redo writes are slow. Check the storage first: put redo on fast disks or flash, not on the same busy disks as the data files. - Use GV$ views to see all instances at once.
V$LOGalready shows every thread, butGV$INSTANCEandGV$SYSSTAT(statistic "redo size") show which instance is generating the most redo.
-- Redo generated per instance since startup (GB) SELECT i.instance_name, i.thread#, ROUND(s.value/1024/1024/1024, 1) AS redo_gb FROM gv$sysstat s JOIN gv$instance i ON i.inst_id = s.inst_id WHERE s.name = 'redo size' ORDER BY i.thread#;
Good practice today
- Size the logs so that each thread switches roughly every 15 to 20 minutes at peak load. Many switches per minute means the logs are too small. The 100 MB groups above would be far too small for most production systems now; 1 to 4 GB is common.
- Use at least 3 groups per thread, not 2, so LGWR never waits for a group that is still ACTIVE or being archived ("checkpoint not complete" in the alert log).
- Multiplex each group with 2 members in different disk groups, such as +DATA and +FRA. The example above has only 1 member per group, so losing one disk could lose a current log.
- Set ARCHIVE_LAG_TARGET (for example 900 seconds) so a quiet instance still switches regularly. This matters with Data Guard, so the standby never falls far behind.
- With Data Guard, create standby redo logs for every thread, the same size as the online logs, with one more group per thread than the online logs.
Adding a redo thread for a new RAC instance
ALTER DATABASE ADD LOGFILE THREAD 5
GROUP 9 ('+DATA','+FRA') SIZE 2G,
GROUP 10 ('+DATA','+FRA') SIZE 2G,
GROUP 11 ('+DATA','+FRA') SIZE 2G;
ALTER DATABASE ENABLE PUBLIC THREAD 5;
When you add an instance with DBCA or srvctl, the thread is usually created for you. Check it afterwards with the queries above.
More current DBA scripts are in my GitHub repository: github.com/sbajwa55/dba-scripts. For help with RAC, Data Guard or migrations to AWS, visit Bajwa Consulting Services.

No comments:
Post a Comment