ORA-00338: log {n} of thread {n} is more recent than control file

I received the following error in a primary database's alert log that I was supporting recently.  

ORA-00312: online log 5 thread 1: '+DATA/db_name/onlinelog/group_5.297.846947859'
ORA-00338: log 5 of thread 1 is more recent than control file


The database has a DataGuard environment as well and below are the steps that I took to resolve the issue.

1.  First, I checked the status of the redo logs and their current sizes and status.

SQL> select group#,bytes/1024/1024,status from v$log;

    GROUP# BYTES/1024/1024 STATUS
---------- --------------- ----------------
         1              50 INACTIVE
         2              50 INACTIVE
         3              50 INACTIVE
         4             250 INACTIVE
         5             250 INACTIVE
         6             250 CURRENT

2.  As you can see, groups 1, 2, 3 have 50 MB redo log group sizes while group 4, 5, 6 are 250 MB redo log group sizes.  This is something that I highly suspect was/is the issue.  So I decided to drop the undersized redo log groups and replace them with the appropriate sized ones.  Being that groups 1, 2, 3 are inactive, I can drop them without any errors.

SQL> alter database drop logfile group 1;

Database altered.

SQL> alter database drop logfile group 2;

Database altered.

SQL> alter database drop logfile group 3;

Database altered.

SQL> alter database add logfile group 1 ('+DATA') SIZE 250M;

Database altered.

SQL> alter database add logfile group 2 ('+DATA') SIZE 250M;

Database altered.

SQL> alter database add logfile group 3 ('+DATA') SIZE 250M;

Database altered.

SQL> select group#,bytes/1024/1024,status from v$log;

    GROUP# BYTES/1024/1024 STATUS
---------- --------------- ----------------
         1             250 UNUSED
         2             250 UNUSED
         3             250 UNUSED
         4             250 INACTIVE
         5             250 INACTIVE
         6             250 CURRENT

3.  Now that the primary database is squared away, I move on to the DataGuard environment.  First, I check the status of each group here as well.

SQL> select group#,bytes/1024/1024,status from v$log order by 1;

    GROUP# BYTES/1024/1024 STATUS
---------- --------------- ----------------
         1              50 CLEARING
         2              50 CLEARING
         3              50 CLEARING
         4             250 CLEARING
         5             250 CLEARING
         6             250 CURRENT

4.  Before I can make any changes to the DG environment, I have to cancel the managed recovery process.  

SQL> alter database recover managed standby database cancel;

Database altered.

5.  Then I clear the logfile groups that I want to drop/readd.  These are the same groups that replaced on the primary.

SQL> alter database clear logfile group 1;

Database altered.

SQL> alter database clear logfile group 2;

Database altered.

SQL> alter database clear logfile group 3;

Database altered.

6.  Notice that the status now saying "UNUSED".  They are safe to drop after I change the standby file management from AUTO to MANUAL.

SQL> select group#,bytes/1024/1024,status from v$log order by 1;

    GROUP# BYTES/1024/1024 STATUS
---------- --------------- ----------------
         1              50 UNUSED
         2              50 UNUSED
         3              50 UNUSED
         4             250 CLEARING
         5             250 CLEARING
         6             250 CURRENT

6 rows selected.


SQL> alter system set standby_file_management='manual';

System altered.

SQL> alter database drop logfile group 1;

Database altered.

SQL> alter database drop logfile group 2;

Database altered.

SQL> alter database drop logfile group 3;

Database altered.


SQL> alter database add logfile group 1 ('+DATA') size 250M;

Database altered.

SQL> alter database add logfile group 2 ('+DATA') size 250M;

Database altered.

SQL> alter database add logfile group 3 ('+DATA') size 250M
SQL> /

Database altered.

SQL> select group#,bytes/1024/1024,status from v$log order by 1;

    GROUP# BYTES/1024/1024 STATUS
---------- --------------- ----------------
         1             250 UNUSED
         2             250 UNUSED
         3             250 UNUSED
         4             250 CLEARING
         5             250 CLEARING
         6             250 CURRENT

6 rows selected.

7.  All looks well now.  Now, I change the standby file management back to AUTO and re-enable the managed recovery process.

SQL> alter system set standby_file_management='AUTO';

System altered.

SQL> alter database recover managed standby database using current logfile disconnect;

Database altered.

Issue should now be resolved.  Hope this helps!

Comments

Popular posts from this blog

RMAN-10038: database session for channel prm3 terminated unexpectedly

ORA-17630: Mismatch in the remote file protocol version client 2 server 3