ORA-19566: exceeded limit of 0 corrupt blocks for file E:\xxxx\.ORA.

时间:2022-07-18 14:38:04
How to Format Corrupted Block Not Part of Any Segment (Doc ID 336133.1)    To BottomTo Bottom    

In this Document
Symptoms
Changes
Cause
Solution
References APPLIES TO:
Oracle Database Cloud Schema Service - Version N/A and later
Oracle Database Exadata Cloud Machine - Version N/A and later
Oracle Database Exadata Express Cloud Service - Version N/A and later
Oracle Cloud Infrastructure - Database Service - Version N/A and later
Oracle Database Backup Service - Version N/A and later
Information in this document applies to any platform.
SYMPTOMS
. Rman backup fails with ORA- error and the block reported corrupt does not belong to any object
. Dbverify shows the block as corrupted
. Corrupted block does not belong to any object CHANGES CAUSE
Corrupted block will still be reported by RMAN and DBV until it is reused and reformatted. SOLUTION
DISCLAIMER :-The steps given in this note are not always guaranteed to work A possible way to fix the problem is provided below. Note that it is not guaranteed to work, but it has been known to resolve the problem in several cases.Also if there are many blocks reported corrupt in a particular datafile pass the highest block number reported corrupt for that datafile, when prompted for blocknumber in Step When an object is recreated the blocks allocated (even corrupted block) to it are returned to free space. There they await reallocation to an object requiring additional space. Once they are reallocated to a new extent for an object and only when any DML operation makes use of these block (Even Corrupted blocks which were in free space and now allocated) they would be reformatted just before the DML operation makes modifcation/use of those blocks. Note that a simple allocation of extent does not format the block. Step allocates the extent and step performs DML operation to make use of allocated block in step so that corrupt block gets reused and formatted. In this note we try to reformat the block manually. Step - Identify corrupt datafile The corruption may be reported at the application level, such as DBV and RMAN, or the alert.log. For example, you may receive the following during your RMAN backups: RMAN-: failure of backup command on <channel_name> channel at // :: ORA-: exceeded limit of corrupt blocks for file E:\xxxx\<datafilename>.ORA. Corrupt block is present in file E:\xxxx\<datafilename>.ORA. Step Run DBV/Rman validate on affected datafile and check for corrupt block Run dbverify on the datafile which reports corrupt block. # dbv userid={system/<password>} file={full path filename} logfile={output filename}
Check the {output filename} for the result Sample Output: DBVERIFY: Release 9.2.0.3. - Production on Thu Aug ::
Copyright (c) , , Oracle Corporation. All rights reserved. DBVERIFY - Verification starting : FILE = E:\xxxx\<datafilename>.ORA Page is marked corrupt *** Corrupt block relative dba: 0x01c0be64 (file , block )
Bad check value found during dbv: Data in bad block - type: format: rdba: 0x0000be64
last change scn: 0x0000. seq: 0x1 flg: 0x05
consistency value in tail: 0x00000001
check value in block header: 0xb964, computed block checksum: 0x2a5a
spare1: 0x0, spare2: 0x0, spare3: 0x0
*** DBVERIFY - Verification complete Total Pages Examined :
Total Pages Processed (Data) :
Total Pages Failing (Data) :
Total Pages Processed (Index):
Total Pages Failing (Index):
Total Pages Processed (Other):
Total Pages Processed (Seg) :
Total Pages Failing (Seg) :
Total Pages Empty :
Total Pages Marked Corrupt :
Note that Block is reported as corrupt in datafile . Or in RMAN: For Entire database Rman> backup validate check logical database ; For specific datafile Rman> backup validate check logical datafile <fileno> ; Once done query SQL>Select * from v$database_block_corruption ; **If large number of blocks are reported, proceed to step instead of step . Step - Check whether block is part of any object - For Small Number of Corrupted Blocks Query dba_extents and cross check the block does not belong to any object : SQL> select segment_name, segment_type, owner
from dba_extents
where file_id = <Absolute file number>
and <corrupted block number> between block_id
and block_id + blocks -; If it doesn't belong to an object, double check if it does exists in dba_free_space : SQL> Select * from dba_free_space where file_id= <Absolute file number>
and <corrupted block number> between block_id and block_id + blocks -; If the block cannot be found on DBA_FREE_SPACE nor DBA_EXTENTS, the block might be a file space usage bitmap and cannot be reformatted. Step - Check whether block is part of any object - For Large Number of Corrupted Blocks If you have already ran rman validate in step go to directly sqlplus script given below to identify the object $ rman target / nocatalog
or
$ rman target sys/ nocatalog run {
allocate channel d1 type disk;
allocate channel d2 type disk;
------------------------------------------------------------------------
-- multiple channels may be allocated for parallelizing purposes
-- depends: RMAN - Min ( MAXOPENFILES , FILESPERSET )
-- Defaults: MAXOPENFILES =, FILESPERSET =
------------------------------------------------------------------------
allocate channel dn type disk;
backup check logical validate database;
} Note: if RDBMS is < 11g and NOARCHIVELOG mode, then db must be in MOUNTED mode *** The RMAN check logical validate database command MUST be executed and completed before going any further.
*** The 'v$database_block_corruption' view gets populated upon this command completion.
*** If not complete, you risk to get invalid/incomplete information from the below step. Run the following sql query to find if the block is in free space or occupied set lines pages
col segment_name format a30 SELECT e.owner, e.segment_type, e.segment_name, e.partition_name, c.file#
, greatest(e.block_id, c.block#) corr_start_block#
, least(e.block_id+e.blocks-, c.block#+c.blocks-) corr_end_block#
, least(e.block_id+e.blocks-, c.block#+c.blocks-)
- greatest(e.block_id, c.block#) + blocks_corrupted
, null description
FROM dba_extents e, v$database_block_corruption c
WHERE e.file_id = c.file#
AND e.block_id <= c.block# + c.blocks -
AND e.block_id + e.blocks - >= c.block#
UNION
SELECT s.owner, s.segment_type, s.segment_name, s.partition_name, c.file#
, header_block corr_start_block#
, header_block corr_end_block#
, blocks_corrupted
, 'Segment Header' description
FROM dba_segments s, v$database_block_corruption c
WHERE s.header_file = c.file#
AND s.header_block between c.block# and c.block# + c.blocks -
UNION
SELECT null owner, null segment_type, null segment_name, null partition_name, c.file#
, greatest(f.block_id, c.block#) corr_start_block#
, least(f.block_id+f.blocks-, c.block#+c.blocks-) corr_end_block#
, least(f.block_id+f.blocks-, c.block#+c.blocks-)
- greatest(f.block_id, c.block#) + blocks_corrupted
, 'Free Block' description
FROM dba_free_space f, v$database_block_corruption c
WHERE f.file_id = c.file#
AND f.block_id <= c.block# + c.blocks -
AND f.block_id + f.blocks - >= c.block#
ORDER BY file#, corr_start_block#; Step - Create a dummy table as user other than SYS and SYSTEM SQL> connect <username>/<password> Create a dummy table in the tablespace containing datafile which has the corrupt block - and use nologging option to prevent redo records from being generated: SQL> create table s (
n number,
c varchar2()
) nologging tablespace <tablespace name having the corrupt block> pctfree ; Different storage parameters can be used to suit the specific environment. We use the PCTFREE to speed up the reformat of the block Verify that the table is created in the correct tablespace by querying user_segments: SQL> select segment_name,tablespace_name from user_segments
where segment_name='S' ; Please note in 11gr2 due to deferred segment creation concept query from above user_segments may not report any rows in such cases query user_tables SQL>Select table_name,tablespace_name from user_tables where table_name='S' ; Step - Create trigger on dummy table which throws exception once the corrupted block is reused Login as SYSDBA Please note when prompted for file number enter the relative file no(rfile# value from v$datafile) CREATE OR REPLACE TRIGGER corrupt_trigger
AFTER INSERT ON <username>.s
REFERENCING OLD AS p_old NEW AS new_p
FOR EACH ROW
DECLARE
corrupt EXCEPTION;
BEGIN
IF (dbms_rowid.rowid_block_number(:new_p.rowid)=&blocknumber)
and (dbms_rowid.rowid_relative_fno(:new_p.rowid)=&filenumber) THEN
RAISE corrupt;
END IF;
EXCEPTION
WHEN corrupt THEN
RAISE_APPLICATION_ERROR(-, 'Corrupt block has been formatted');
END;
/ When prompted for the block number, provide the block reported corrupt as input.
When prompted for the file number enter the relative fileno (rfile# value from v$datafile) for corrupt datafile. Step - Allocate space to the table from the affected datafile Notes
) If this is an ASSM tablespace, you may need to repeat this step a few times. That is, create multiple tables and allocate multiple extents.
And periodically look at dba_extents to ensure that the free space is now allocated to a dummy table. This is because ASSM will automatically determine the size of the next extent
) It is advisable to ensure that AUTOEXTEND is OFF for the datafile, to prevent it from growing Please note :- If your database is on 10.2.0.4/11.1.0.7 and tablespace in which dummy table is created is ASSM then you might hit the below bug while manually Allocating extent to the dummy table. Ensure for 10.2.0.4/11.1.0.7 database you have the below fix installed before Manually allocating extents.Ensure you have One off patch applied for 10.2.0.4/11.1.0.7 database version. Bug - Corruption / OERI [kddummy_blkchk] .. [] with ASSM (Doc ID 6647480.8) Firstly, find the extent size by querying dba_free_space SQL> Select BYTES from dba_free_space where file_id=<file no> and <corrupt block no> between block_id and block_id + blocks -; BYTES
---------------- ---------- ---------- ---------- ---------- ------------ In this case it's 64K, so allocate the extent as follows: SQL> alter table <username>.s
allocate extent (DATAFILE 'E:\xxxx\<datafilename>.ORA' SIZE 64K); If there are multiple extents of 64K free in this datafile, you may need use this loop: BEGIN
for i in .. loop
EXECUTE IMMEDIATE 'alter table <username>.s allocate extent (DATAFILE '||'''E:\xxxx\<datafilename>.ORA''' ||'SIZE 64K) ';
end loop;
end ;
/ Keep allocating until the corrupted block is part of <username>.s. Use this query to confirm thus: SQL> select segment_name, segment_type, owner
from dba_extents
where file_id = <Absolute file number>
and <corrupt block number> between block_id
and block_id + blocks - ; Step - Insert data into dummy table to format the block Sample code (depending on the size of the tablespace it may vary): BEGIN
FOR i IN .. LOOP
INSERT /*+ APPEND */ INTO <username>.s select i, lpad('REFORMAT',, 'R') from dual;
commit ;
END LOOP;
END; Or BEGIN
FOR i IN .. LOOP
INSERT INTO <username>.s VALUES(i,'x');
END LOOP;
END;
/
Or use the below code which includes loops: Begin
FOR i IN .. loop
for j IN .. loop
Insert into <username>.s VALUES(i,'x');
end loop;
commit;
END LOOP;
END; The trigger will be fired for every row inserted into the table and an exception with ORA- will be produced as soon as it inserts the first row into the corrupt block. Step - Confirm that the block is now corruption free Run dbverify or RMAN validate on the corrupt datafile (or entire database) again. It will not show the block as corrupted. Ensure you do couple of manual logswitch or checkpoint for information in memory to be written to disk. RMAN backup will not report any error on this block. Before running the actual backup you can re-run Rman validate command on the datafile and check v$database_block_corruption doesnot show the block formatted as corrupted. For Db version <=10gr2 Rman> Backup validate check logical datafile <fileno>,<fileno> ; For Db version >= 11gr1 Rman> Backup validate check logical datafile <fileno> ; Or Rman> validate datafile <fileno> block <blockno reported corrupt>, <blockno reported corrupt> ; Once done SQL>Select * from v$database_block_corruption ; Step - Drop the dummy table created in step SQL> DROP TABLE <username>.s ; If 10gr1 and above drop table with purge option. Step :- Do a Manual logswitch and checkpoint Do couple of logswitch and checkpoint so that The block formatted in-memory are written into disk and dbverify no longer reports errors SQL>Alter system switch logfile ; --> Do this couple of time SQL>Alter system checkpoint ; Step :- Drop trigger created in step SQL> DROP trigger corrupt_trigger ; Important: Bug - ORA- Free corrupt blocks may not be reformatted when Flashback is enabled