Friday, 19 February 2010


Fixing Corrupt System Managed

In Oracle9i and greater releases of Oracle the old rollback segment has been replaced with undo segments and for the most part, have become automatically sized and managed. However, what happens when one of these system created and managed undo segments becomes corrupt? Well, for one thing you will get errors in your alert log similar to the following:

Errors in file /oracle/admin/test/bdump/test2_smon_21466.trc:
ORA-00600: internal error code, arguments: [6006], [1], [], [], [], [], [], []
SMON: mark undo segment 29 as needs recovery

ORACLE Instance test2 (pid = 11) - Error 600 encountered while recovering 
transaction (29, 42) on object 36.

(Note that this will show the same undo segment, transaction, and object number each time it occurs, if the undo segment and transaction number vary, then the problem is with the object number displayed)

In fact, you may get many of these over and over again.

So, what can you do about this?

If you attempt to alter the undo segment with the ALTER ROLLBACK SEGMENT command you will be told in no uncertain terms that this is system managed and can't be altered.

So, here is what you need to do:

  1. Create a new system management undo tablespace:

           SQL> connect / as sysdba

 SQL> create undo tablespace undotbs2 datafile                        '/u02/oracle/oradata/test/undotbs2.dbf' size 500m;

  1. Determine the problem undo segment:

           SQL> select SEGMENT_NAME, STATUS from dba_rollback_segs;

 The problem segment will show a "Needs Recovery" status.

  1. Alter the system to use the new undo tablespace:

 SQL> alter system set undo_tablespace=undotbs2 scope=both;  (Note if you are not using an spfile, omit the scope command) 

  1. If you are using an spfile, create a pfile from it:

          SQL> connect / as sysdba

          SQL> create pfile='/u01/oracle/admin/test/pfile/inittest.ora' from spfile; 

  1. Edit the inittest.ora pfile and add (using the undo segment from our example error):

   *._offline_rollback_segments=" _SYSSMU29$"


  1. Now shutdown your instance, this may require a shutdown abort, but try a shutdown immediate first.
  2. Startup using the manual startup command:

    SQL> startup pfile='/u01/oacle/admin/test/pfile=inittest.ora' 

  1. Alter the old undo tablespace offline:

         SQL> alter tablespace undotbs1 offline; 

  1. Drop the offending tablespace:

         SQL> drop tablespace undotbs1 including contents and datafiles; 

  1. Shut down immediate.
  2. Edit the inittest.ora file to eliminate the underscore parameters.
  3. Restart the instance using the pfile option.
  4. Create an spfile from the pfile:

           SQL> create spfile from pfile='/u01/oracle/admin/test/pfile/inittest.ora';

Once step 13 is accomplished the database should be up normally. However, it might be wise to do a full backup and then rebuild using an export and import. Since we had to drop a undo segment that had some possibly active transactions un-applied the database may not be fully consistent.

No comments: