Thursday, February 18, 2016

Another Corrupt Block in Oracle 11g - fixed

2016_06_13 update
Another bad block located:
SQL Error: ORA-01578: ORACLE data block corrupted (file # 8, block # 61663)ORA-01110: data file 8: '/home/oracle/app/oracle/oradata/orcl/HYP_DM_TBL_3.DBF'

Then to fix this one I had to find the problem using:
select owner, segment_type, segment_namefrom dba_extentswhere file_id=8  and 61663  between block_id and block_id+blocks-1;
Located the ROWS that were good with this command:

select * from entity_Hour_fact where ROWNUM <2127000 order by 2;
Anything more would error with this:
SQL Error: ORA-01578: ORACLE data block corrupted (file # 8, block # 61663)ORA-01110: data file 8: '/home/oracle/app/oracle/oradata/orcl/HYP_DM_TBL_3.DBF'01578. 00000 -  "ORACLE data block corrupted (file # %s, block # %s)" *Cause:    The data block indicated was corrupt. This was a physical           corruption, also called a media corruption. The cause is unknown           but is most likely external to the database. If ORA-26040 is also           signaled, the corruption is due to NOLOGGING or UNRECOVERABLE           operations.
Will copy the old file to a new filename:
with a CTAS command:

Create Table As Select...

scroll down to see older examples.

------------------------------------------------
2016_02_18

After more bad blocks...I replaced the SSD drive.

Error in Enterprise Manager:
ORA-1578 [ORA-01578: ORACLE data block corrupted (file # 2, block # 35170)]

Error in CCC.LOG file was this:
----
### The error may exist in com/hyperformix/pb/server/mapper/IAnalyzeMapper.java (best guess)
### The error may involve defaultParameterMap
### The error occurred while setting parameters
### SQL: call DATAMART_LIB.Analyze_pb_objects()
### Cause: java.sql.SQLException:
ORA-01578: ORACLE data block corrupted (file # 2, block # 35170)
ORA-01110: data file 2: '/home/oracle/app/oracle/oradata/orcl/sysaux01.dbf'
ORA-06512: at "SYS.DBMS_STATS", line 20337
ORA-06512: at "SYS.DBMS_STATS", line 20360
ORA-06512: at "HYP_CCC9.DATAMART_LIB", line 2472
----

Then to fix this one I had to find the problem using:

select owner, segment_type, segment_name
from dba_extents
where file_id=2  and 35170  between block_id and block_id+blocks-1;
This returns:
OWNER                          SEGMENT_TYPE   SEGMENT_NAME                                               
------------------------------ ------------------       -------------------------------------------------------
SYS                                  TABLE                   WRI$_OPTSTAT_HISTGRM_HSTRY_BAD         
Using this I found that it was in the SYSAUX tablespace.

So I moved it to the SYSAUX1 tablespace, which was empty.

So I renamed the table to have a _ on the end and copied the Index definitions.

Then I use a CTAS method to copy the table.
SELECT * FROM TABLENAME WHERE ROWNUM < 410000
This allows me to get most of the table and stop pulling data before I hit the Corrupted Block.

select * from SYS.WRI$_OPTSTAT_HISTGRM_HISTORY_ where rownum < 410000 order by 3;

It was trial and error using first ROWNUM of 1000, 5000, 100000, 1000000 till I hit the error and then backed down until I got no error.

This was the CTAS command I used:

CREATE    TABLE SYS.WRI$_OPTSTAT_HISTGRM_HISTORY TABLESPACE SYSAUX1 STORAGE    (      INITIAL 500m NEXT 50m maxextents unlimited    )    parallel    (      degree 4    ) ASSELECT    *  FROM    SYS.WRI$_OPTSTAT_HISTGRM_HISTORY_  WHERE    rownum < 410000  ORDER BY    3;
These are the indexes:

  CREATE INDEX "SYS"."I_WRI$_OPTSTAT_H_OBJ#_ICOL#_ST" ON "SYS"."WRI$_OPTSTAT_HISTGRM_HISTORY" ("OBJ#", "INTCOL#", SYS_EXTRACT_UTC("SAVTIME"), "COLNAME")   PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS   STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645  PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)  TABLESPACE "SYSAUX1" ; 
  CREATE INDEX "SYS"."I_WRI$_OPTSTAT_H_ST" ON "SYS"."WRI$_OPTSTAT_HISTGRM_HISTORY" (SYS_EXTRACT_UTC("SAVTIME"))   PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS   STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645  PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)  TABLESPACE "SYSAUX1" ;
I did NOT delete the original table space I just kept it and renamed it to:

alter table "SYS"."WRI$_OPTSTAT_HISTGRM_HISTORY_" rename to WRI$_OPTSTAT_HISTGRM_HSTRY_BAD;
If I delete the bad table then the Corrupt block may get used again...

1 comment:

  1. Added new data on this type of error today...is at the top of this post.

    ReplyDelete