Skip to main content

How to fix ORA-26040: Data block was loaded using the NOLOGGING option

Today I faced with new ORA error. After solving I want to share this experience with yours.

So, today 5`th datafile of my database was corrupted (/u01/app/oracle/oradata/ulfet_db/example01.dbf).
After recover via RMAN I saw strange error.


RMAN> recover datafile 5 block 443;
Starting recover at 24-MAR-13
using channel ORA_DISK_1
channel ORA_DISK_1: restoring block(s)
channel ORA_DISK_1: specifying block(s) to restore from backup set
restoring blocks of datafile 00005
channel ORA_DISK_1: reading from backup piece /u01/app/oracle/flash_recovery_area/ULFET_DB/backupset/2013_03_24/o1_mf_nnndf_TAG20130324T223233_8nykp220_.bkp
channel ORA_DISK_1: piece handle=/u01/app/oracle/flash_recovery_area/ULFET_DB/backupset/2013_03_24/o1_mf_nnndf_TAG20130324T223233_8nykp220_.bkp tag=TAG20130324T223233
channel ORA_DISK_1: restored block(s) from backup piece 1
channel ORA_DISK_1: block restore complete, elapsed time: 00:00:03

starting media recovery
media recovery complete, elapsed time: 00:00:04
Finished recover at 24-MAR-13
RMAN>



SQL> select count(1) from block_corrupt_test;
select count(1) from block_corrupt_test
                     *
ERROR at line 1:
ORA-01578: ORACLE data block corrupted (file # 5, block # 443)
ORA-01110: data file 5: '/u01/app/oracle/oradata/ulfet_db/example01.dbf'
ORA-26040: Data block was loaded using the NOLOGGING option


col segment_name format a20
col tablespace_name format a15

SQL> select owner, segment_name, tablespace_name from dba_extents where FILE_ID=5 and 443 between BLOCK_ID and BLOCK_ID+BLOCKS;

OWNER                       SEGMENT_NAME               TABLESPACE_NAME
------------------------ --------------------                  ---------------
SYS                              BLOCK_CORRUPT_TEST   EXAMPLE

Using dbv utility to clarify datafile corruption  

[oracle@localhost ~]$ dbv file=/u01/app/oracle/oradata/ulfet_db/example01.dbf

DBVERIFY: Release 11.2.0.1.0 - Production on Sun Mar 24 22:57:06 2013

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

DBVERIFY - Verification starting : FILE = /u01/app/oracle/oradata/ulfet_db/example01.dbf

DBV-00201: Block, DBA 20971963, marked corrupt for invalid redo application


DBVERIFY - Verification complete

Total Pages Examined         : 12800
Total Pages Processed (Data) : 6586
Total Pages Failing   (Data) : 0
Total Pages Processed (Index): 1261
Total Pages Failing   (Index): 0
Total Pages Processed (Other): 3251
Total Pages Processed (Seg)  : 0
Total Pages Failing   (Seg)  : 0
Total Pages Empty            : 1702
Total Pages Marked Corrupt   : 1
Total Pages Influx           : 0
Total Pages Encrypted        : 0
Highest block SCN            : 1377097 (0.1377097)
[oracle@localhost ~]$ 

Use below query to get block error and file_name:

SQL> select dbms_utility.data_block_address_block('20971963') block_no,
dbms_utility.data_block_address_file('20971963') file_no
from dual;

  BLOCK_NO    FILE_NO
---------- ----------
       443          5

SQL> 

Now follow up below statements:

Create the repair table (in tablespace where corrupted table resides)

SQL> BEGIN
DBMS_REPAIR.ADMIN_TABLES (
TABLE_NAME => 'REPAIR_TABLE',
TABLE_TYPE => dbms_repair.repair_table,
ACTION => dbms_repair.create_action,
TABLESPACE => 'example');
END;
/  2    3    4    5    6    7    8  

PL/SQL procedure successfully completed.

SQL> 

Identify corrupted blocks:

SQL> set serveroutput on
DECLARE num_corrupt INT;
BEGIN
num_corrupt := 0;
DBMS_REPAIR.CHECK_OBJECT (
SCHEMA_NAME => 'SYS',
OBJECT_NAME => 'BLOCK_CORRUPT_TEST',
REPAIR_TABLE_NAME => 'REPAIR_TABLE',
corrupt_count => num_corrupt);
DBMS_OUTPUT.PUT_LINE('number corrupt: ' || TO_CHAR (num_corrupt));
END;
/SQL>   2    3    4    5    6    7    8    9   10   11  
number corrupt: 1

PL/SQL procedure successfully completed.

SQL> 


Show corrupted blocks:

SQL> select BLOCK_ID, CORRUPT_TYPE from REPAIR_TABLE;

BLOCK_ID CORRUPT_TYPE
---------- ------------
       443         6148

SQL> 


Mark the identified blocks as corrupted:

SQL> DECLARE num_fix INT;
BEGIN
num_fix := 0;
DBMS_REPAIR.FIX_CORRUPT_BLOCKS (
SCHEMA_NAME => 'SYS',
OBJECT_NAME=> 'BLOCK_CORRUPT_TEST',
OBJECT_TYPE => dbms_repair.table_object,
REPAIR_TABLE_NAME => 'REPAIR_TABLE',
FIX_COUNT=> num_fix);
DBMS_OUTPUT.PUT_LINE('num fix: ' || to_char(num_fix));
END;
/  2    3    4    5    6    7    8    9   10   11   12  

PL/SQL procedure successfully completed.

SQL> 

Allow in the future DML statements to skip the corrupted blocks:

SQL> BEGIN
DBMS_REPAIR.SKIP_CORRUPT_BLOCKS (
SCHEMA_NAME => 'SYS',
OBJECT_NAME => 'BLOCK_CORRUPT_TEST',
OBJECT_TYPE => dbms_repair.table_object,
FLAGS => dbms_repair.SKIP_FLAG);
END;
/  2    3    4    5    6    7    8  

PL/SQL procedure successfully completed.

SQL> 


Now, check table again:

SQL> select count(1) from block_corrupt_test;
COUNT(1)
------------
10


Comments

  1. Perhaps I am wrong, but this is more like a workaorund rather than a "fix".

    Another method to approach this would be to drop the object with the bad block, and perhaps even vacate the entire tablespace, drop and recreate it.

    ReplyDelete
  2. Dear Michael,

    firstly thank you for your comment. Yes, we can drop table and recover entry tablespace which damage table was located (Tablespace Point in Time Recovery). But in this topic I tried to fix corrupted blocks using DBMS_REPAIR package.

    ReplyDelete

Post a Comment

Popular posts from this blog

Rman encryption and other techniques

Today I will demonstrate Recovery Manager features, especially encryption and some other techniques. First of all let me note about RMAN backup encryption. Staring from Oracle 10g RMAN now creates encrypted backups that cannot be restored by unauthorized people. There are 3 modes of backup encryption: * Transparent encryption * Password encryption * Dual-mode encryption using either transparent or password encryption All RMAN backups are not encrypted but you can encrypt any RMAN backup in the form of a backup set. In this tutorial I will show you how to configure Password encryption. Let`s finish talking and start to demonstrate. check parameters with "SHOW ALL" command, by default encryption is OFF RMAN> show all; RMAN configuration parameters are: CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default CONFIGURE BACKUP OPTIMIZATION OFF; # default CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default CONFIGURE CONTROLFILE AUTOBACKUP ON; CONFIGURE CONTR...

ORA-03206: maximum file size of (5242880) blocks in AUTOEXTEND clause is out of range

Today when I want to change max size of datafile I got strange error. ALTER DATABASE DATAFILE '/u01/app/oracle/oradata/MYDB/users01.dbf' AUTOEXTEND ON NEXT 1280K MAXSIZE 32GB ORA-03206: maximum file size of (5242880) blocks in AUTOEXTEND clause is out of range Here is reason: The maximum file size for an autoextendable file has exceeded the maximum number of blocks allowed. After research internet I found that instead of using 32GB we can use 32767M. (same values but in MB). Or you may use 31GB too. ALTER DATABASE DATAFILE '/u01/app/oracle/oradata/MYDB/users01.dbf' AUTOEXTEND ON NEXT 1280K MAXSIZE 32767M;

Fix ORA-01139: RESETLOGS option only valid after an incomplete database recovery

While shutting down my TEST database process was hanged. Then I had to use shutdown abort. But when I wanted to start database it did not open. SQL> select name from v$database; NAME --------- TEST SQL> shut abort; ORACLE instance shut down. SQL> startup mount ORACLE instance started. Total System Global Area 6597406720 bytes Fixed Size 2265664 bytes Variable Size 3204451776 bytes Database Buffers 3372220416 bytes Redo Buffers 18468864 bytes Database mounted. SQL> alter database open; alter database open * ERROR at line 1: ORA-03113: end-of-file on communication channel Process ID: 6552 Session ID: 191 Serial number: 3  What`s wrong?  SQL> alter database open resetlogs; ERROR:    ORA-03114: not connected to ORACLE    SQL> exit Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Pr...