Quantcast
Channel: Thinking Out Loud
Viewing all articles
Browse latest Browse all 666

Playing with Oracle Free Block Corruption

$
0
0

First and foremost, thank you to all the bloggers sharing their knowledge.

My previous post on corruption is here
The corrupt.sql script was stolen from here
exec SYS.DBMS_BACKUP_RESTORE.resetCfileSection(35) was stolen from here

Free Block Corruption is from a data file block which is now Free but used to be occupied by a corrupted segment.

How to Format Corrupted Block Not Part of Any Segment (Doc ID 336133.1) is a good reference.

So how did I get here?

The objective is to remove rows from v$database_block_corruption and this can be done by running exec SYS.DBMS_BACKUP_RESTORE.resetCfileSection(35).

The caveat is when the next corruption check, v$database_block_corruption is populated again.

This appears to only treat the symptoms and not the root cause.

Here’s my test case:

LAX:(SYS@db01)> create tablespace corrupt datafile size 16m;

Tablespace created.

LAX:(SYS@db01)> create index hr.x on hr.departments_old(last_update) tablespace corrupt;

Index created.

LAX:(SYS@db01)> exit

$ rman target /

Recovery Manager: Release 11.2.0.3.0 - Production on Tue Oct 29 22:45:58 2013

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

connected to target database: DB01 (DBID=1452485914)

RMAN> validate tablespace corrupt;

Starting validate at 29-OCT-2013 22:46:05
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=34 device type=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: SID=37 device type=DISK
channel ORA_DISK_1: starting validation of datafile
channel ORA_DISK_1: specifying datafile(s) for validation
input datafile file number=00005 name=/oracle/datafilecopy/LAX_DB01/datafile/o1_mf_corrupt_97177krz_.dbf
channel ORA_DISK_1: validation complete, elapsed time: 00:00:01
List of Datafiles
=================

File Status Marked Corrupt Empty Blocks Blocks Examined High SCN
---- ------ -------------- ------------ --------------- ----------
5    OK     0              1917         2048            1833133
  File Name: /oracle/datafilecopy/LAX_DB01/datafile/o1_mf_corrupt_97177krz_.dbf
  Block Type Blocks Failing Blocks Processed
  ---------- -------------- ----------------
  Data       0              0
  Index      0              1
  Other      0              130

Finished validate at 29-OCT-2013 22:46:07

RMAN> exit

LAX:(SYS@db01)> @corrupt.sql

dd of=/oracle/datafilecopy/LAX_DB01/datafile/o1_mf_corrupt_97177krz_.dbf bs=8192 conv=notrunc seek=1051 << EOF
CORRUPT corrupt CORRUPT corrupt CORRUPT corrupt CORRUPT corrupt CORRUPT CORRUPT CORRUPT CORRUPT corrupt corrupt
EOF

dd of=/oracle/datafilecopy/LAX_DB01/datafile/o1_mf_corrupt_97177krz_.dbf bs=8192 conv=notrunc seek=1043 << EOF
CORRUPT corrupt CORRUPT corrupt CORRUPT corrupt CORRUPT corrupt CORRUPT CORRUPT CORRUPT CORRUPT corrupt corrupt
EOF

dd of=/oracle/datafilecopy/LAX_DB01/datafile/o1_mf_corrupt_97177krz_.dbf bs=8192 conv=notrunc seek=1047 << EOF
CORRUPT corrupt CORRUPT corrupt CORRUPT corrupt CORRUPT corrupt CORRUPT CORRUPT CORRUPT CORRUPT corrupt corrupt
EOF

dd of=/oracle/datafilecopy/LAX_DB01/datafile/o1_mf_corrupt_97177krz_.dbf bs=8192 conv=notrunc seek=1045 << EOF
CORRUPT corrupt CORRUPT corrupt CORRUPT corrupt CORRUPT corrupt CORRUPT CORRUPT CORRUPT CORRUPT corrupt corrupt
EOF

dd of=/oracle/datafilecopy/LAX_DB01/datafile/o1_mf_corrupt_97177krz_.dbf bs=8192 conv=notrunc seek=1034 << EOF
CORRUPT corrupt CORRUPT corrupt CORRUPT corrupt CORRUPT corrupt CORRUPT CORRUPT CORRUPT CORRUPT corrupt corrupt
EOF

dd of=/oracle/datafilecopy/LAX_DB01/datafile/o1_mf_corrupt_97177krz_.dbf bs=8192 conv=notrunc seek=2308 << EOF
CORRUPT corrupt CORRUPT corrupt CORRUPT corrupt CORRUPT corrupt CORRUPT CORRUPT CORRUPT CORRUPT corrupt corrupt
EOF

dd of=/oracle/datafilecopy/LAX_DB01/datafile/o1_mf_corrupt_97177krz_.dbf bs=8192 conv=notrunc seek=2274 << EOF
CORRUPT corrupt CORRUPT corrupt CORRUPT corrupt CORRUPT corrupt CORRUPT CORRUPT CORRUPT CORRUPT corrupt corrupt
EOF

dd of=/oracle/datafilecopy/LAX_DB01/datafile/o1_mf_corrupt_97177krz_.dbf bs=8192 conv=notrunc seek=2258 << EOF
CORRUPT corrupt CORRUPT corrupt CORRUPT corrupt CORRUPT corrupt CORRUPT CORRUPT CORRUPT CORRUPT corrupt corrupt
EOF

dd of=/oracle/datafilecopy/LAX_DB01/datafile/o1_mf_corrupt_97177krz_.dbf bs=8192 conv=notrunc seek=2292 << EOF
CORRUPT corrupt CORRUPT corrupt CORRUPT corrupt CORRUPT corrupt CORRUPT CORRUPT CORRUPT CORRUPT corrupt corrupt
EOF

dd of=/oracle/datafilecopy/LAX_DB01/datafile/o1_mf_corrupt_97177krz_.dbf bs=8192 conv=notrunc seek=2362 << EOF
CORRUPT corrupt CORRUPT corrupt CORRUPT corrupt CORRUPT corrupt CORRUPT CORRUPT CORRUPT CORRUPT corrupt corrupt
EOF

dd of=/oracle/datafilecopy/LAX_DB01/datafile/o1_mf_corrupt_97177krz_.dbf bs=8192 conv=notrunc seek=2244 << EOF
CORRUPT corrupt CORRUPT corrupt CORRUPT corrupt CORRUPT corrupt CORRUPT CORRUPT CORRUPT CORRUPT corrupt corrupt
EOF

dd of=/oracle/datafilecopy/LAX_DB01/datafile/o1_mf_corrupt_97177krz_.dbf bs=8192 conv=notrunc seek=2390 << EOF
CORRUPT corrupt CORRUPT corrupt CORRUPT corrupt CORRUPT corrupt CORRUPT CORRUPT CORRUPT CORRUPT corrupt corrupt
EOF

dd of=/oracle/datafilecopy/LAX_DB01/datafile/o1_mf_corrupt_97177krz_.dbf bs=8192 conv=notrunc seek=2283 << EOF
CORRUPT corrupt CORRUPT corrupt CORRUPT corrupt CORRUPT corrupt CORRUPT CORRUPT CORRUPT CORRUPT corrupt corrupt
EOF

dd of=/oracle/datafilecopy/LAX_DB01/datafile/o1_mf_corrupt_97177krz_.dbf bs=8192 conv=notrunc seek=2228 << EOF
CORRUPT corrupt CORRUPT corrupt CORRUPT corrupt CORRUPT corrupt CORRUPT CORRUPT CORRUPT CORRUPT corrupt corrupt
EOF

dd of=/oracle/datafilecopy/LAX_DB01/datafile/o1_mf_corrupt_97177krz_.dbf bs=8192 conv=notrunc seek=2304 << EOF
CORRUPT corrupt CORRUPT corrupt CORRUPT corrupt CORRUPT corrupt CORRUPT CORRUPT CORRUPT CORRUPT corrupt corrupt
EOF

dd of=/oracle/datafilecopy/LAX_DB01/datafile/o1_mf_corrupt_97177krz_.dbf bs=8192 conv=notrunc seek=2234 << EOF
CORRUPT corrupt CORRUPT corrupt CORRUPT corrupt CORRUPT corrupt CORRUPT CORRUPT CORRUPT CORRUPT corrupt corrupt
EOF

dd of=/oracle/datafilecopy/LAX_DB01/datafile/o1_mf_corrupt_97177krz_.dbf bs=8192 conv=notrunc seek=2238 << EOF
CORRUPT corrupt CORRUPT corrupt CORRUPT corrupt CORRUPT corrupt CORRUPT CORRUPT CORRUPT CORRUPT corrupt corrupt
EOF

dd of=/oracle/datafilecopy/LAX_DB01/datafile/o1_mf_corrupt_97177krz_.dbf bs=8192 conv=notrunc seek=827 << EOF
CORRUPT corrupt CORRUPT corrupt CORRUPT corrupt CORRUPT corrupt CORRUPT CORRUPT CORRUPT CORRUPT corrupt corrupt
EOF

dd of=/oracle/datafilecopy/LAX_DB01/datafile/o1_mf_corrupt_97177krz_.dbf bs=8192 conv=notrunc seek=843 << EOF
CORRUPT corrupt CORRUPT corrupt CORRUPT corrupt CORRUPT corrupt CORRUPT CORRUPT CORRUPT CORRUPT corrupt corrupt
EOF

dd of=/oracle/datafilecopy/LAX_DB01/datafile/o1_mf_corrupt_97177krz_.dbf bs=8192 conv=notrunc seek=835 << EOF
CORRUPT corrupt CORRUPT corrupt CORRUPT corrupt CORRUPT corrupt CORRUPT CORRUPT CORRUPT CORRUPT corrupt corrupt
EOF

dd of=/oracle/datafilecopy/LAX_DB01/datafile/o1_mf_corrupt_97177krz_.dbf bs=8192 conv=notrunc seek=131 << EOF 
CORRUPT corrupt CORRUPT corrupt CORRUPT corrupt CORRUPT corrupt CORRUPT CORRUPT CORRUPT CORRUPT corrupt corrupt 
EOF 

21 rows selected. 

LAX:(SYS@db01)> exit

[oracle@lax:db01]/home/oracle
$ dd of=/oracle/datafilecopy/LAX_DB01/datafile/o1_mf_corrupt_97177krz_.dbf bs=8192 conv=notrunc seek=131 << EOF 
> CORRUPT corrupt CORRUPT corrupt CORRUPT corrupt CORRUPT corrupt CORRUPT CORRUPT CORRUPT CORRUPT corrupt corrupt
> EOF
0+1 records in
0+1 records out
112 bytes (112 B) copied, 0.000109233 s, 1.0 MB/s


RMAN> validate tablespace corrupt;

Starting validate at 29-OCT-2013 22:46:42
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=33 device type=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: SID=16 device type=DISK
channel ORA_DISK_1: starting validation of datafile
channel ORA_DISK_1: specifying datafile(s) for validation
input datafile file number=00005 name=/oracle/datafilecopy/LAX_DB01/datafile/o1_mf_corrupt_97177krz_.dbf
channel ORA_DISK_1: validation complete, elapsed time: 00:00:03
List of Datafiles
=================

File Status Marked Corrupt Empty Blocks Blocks Examined High SCN
---- ------ -------------- ------------ --------------- ----------
5    FAILED 0              1917         2048            1833132
  File Name: /oracle/datafilecopy/LAX_DB01/datafile/o1_mf_corrupt_97177krz_.dbf
  Block Type Blocks Failing Blocks Processed
  ---------- -------------- ----------------
  Data       0              0
  Index      0              0
  Other      1              131

validate found one or more corrupt blocks

See trace file /u01/app/oracle/diag/rdbms/lax_db01/db01/trace/db01_ora_3351.trc for details
Finished validate at 29-OCT-2013 22:46:46

RMAN> exit

LAX:(SYS@db01)> @corrupt_seg.sql
LAX:(SYS@db01)> col OWNER for a20
LAX:(SYS@db01)> col FILE# for 999
LAX:(SYS@db01)> col BLOCK# for 99999
LAX:(SYS@db01)> col BLOCKS for 99999
LAX:(SYS@db01)> col s_blk# for 99999
LAX:(SYS@db01)> col e_blk# for 99999
LAX:(SYS@db01)> col CORRUPTION_CHANGE# for 999999999999
LAX:(SYS@db01)> col SEGMENT_NAME for a25
LAX:(SYS@db01)> col PARTITION_NAME for a25
LAX:(SYS@db01)> select instance_name from v$instance
  2  ;

INSTANCE_NAME
----------------
db01

LAX:(SYS@db01)> select * from v$database_block_corruption order by 1,2,3,4
  2  ;

FILE# BLOCK# BLOCKS CORRUPTION_CHANGE# CORRUPTIO
----- ------ ------ ------------------ ---------
    5    131      1                  0 CORRUPT

LAX:(SYS@db01)>
LAX:(SYS@db01)> SELECT e.owner, e.segment_type, e.segment_name, e.partition_name, c.file#
  2         , greatest(e.block_id, c.block#) s_blk#
  3         , least(e.block_id+e.blocks-1, c.block#+c.blocks-1) e_dblk#
  4         , least(e.block_id+e.blocks-1, c.block#+c.blocks-1)
  5         - greatest(e.block_id, c.block#) + 1 blk_corrupt
  6        , null description
  7  FROM dba_extents e, v$database_block_corruption c
  8  WHERE e.file_id = c.file#
  9  AND e.block_id <= c.block# + c.blocks - 1  10  AND e.block_id + e.blocks - 1 >= c.block#
 11  UNION
 12  SELECT s.owner, s.segment_type, s.segment_name, s.partition_name, c.file#
 13         , header_block s_blk#
 14         , header_block e_blk#
 15         , 1 blk_corrupt
 16         , 'Segment Header' description
 17  FROM dba_segments s, v$database_block_corruption c
 18  WHERE s.header_file = c.file#
 19  AND s.header_block between c.block# and c.block# + c.blocks - 1
 20  UNION
 21  SELECT null owner, null segment_type, null segment_name, null partition_name, c.file#
 22         , greatest(f.block_id, c.block#) s_blk#
 23         , least(f.block_id+f.blocks-1, c.block#+c.blocks-1) e_blk#
 24         , least(f.block_id+f.blocks-1, c.block#+c.blocks-1)
 25         - greatest(f.block_id, c.block#) + 1 blk_corrupt
 26         , 'Free Block' description
 27  FROM dba_free_space f, v$database_block_corruption c
 28  WHERE f.file_id = c.file#
 29  AND f.block_id <= c.block# + c.blocks - 1  30  AND f.block_id + f.blocks - 1 >= c.block#
 31  order by file#, s_blk#
 32  ;

OWNER                SEGMENT_TYPE       SEGMENT_NAME              PARTITION_NAME            FILE# S_BLK#    E_DBLK# BLK_CORRUPT DESCRIPTION
-------------------- ------------------ ------------------------- ------------------------- ----- ------ ---------- ----------- --------------
HR                   INDEX              X                                                       5    131        131           1

LAX:(SYS@db01)> drop index hr.x;

Index dropped.

LAX:(SYS@db01)>

RMAN> validate tablespace corrupt;

Starting validate at 29-OCT-2013 22:49:56
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=34 device type=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: SID=37 device type=DISK
channel ORA_DISK_1: starting validation of datafile
channel ORA_DISK_1: specifying datafile(s) for validation
input datafile file number=00005 name=/oracle/datafilecopy/LAX_DB01/datafile/o1_mf_corrupt_97177krz_.dbf
channel ORA_DISK_1: validation complete, elapsed time: 00:00:03
List of Datafiles
=================

File Status Marked Corrupt Empty Blocks Blocks Examined High SCN
---- ------ -------------- ------------ --------------- ----------
5    FAILED 0              1917         2048            1833264
  File Name: /oracle/datafilecopy/LAX_DB01/datafile/o1_mf_corrupt_97177krz_.dbf
  Block Type Blocks Failing Blocks Processed
  ---------- -------------- ----------------
  Data       0              0
  Index      0              0
  Other      1              131

validate found one or more corrupt blocks

See trace file /u01/app/oracle/diag/rdbms/lax_db01/db01/trace/db01_ora_3364.trc for details
Finished validate at 29-OCT-2013 22:50:00

RMAN>

LAX:(SYS@db01)> @corrupt_seg.sql
LAX:(SYS@db01)> col OWNER for a20
LAX:(SYS@db01)> col FILE# for 999
LAX:(SYS@db01)> col BLOCK# for 99999
LAX:(SYS@db01)> col BLOCKS for 99999
LAX:(SYS@db01)> col s_blk# for 99999
LAX:(SYS@db01)> col e_blk# for 99999
LAX:(SYS@db01)> col CORRUPTION_CHANGE# for 999999999999
LAX:(SYS@db01)> col SEGMENT_NAME for a25
LAX:(SYS@db01)> col PARTITION_NAME for a25
LAX:(SYS@db01)> select instance_name from v$instance
  2  ;

INSTANCE_NAME
----------------
db01

LAX:(SYS@db01)> select * from v$database_block_corruption order by 1,2,3,4
  2  ;

FILE# BLOCK# BLOCKS CORRUPTION_CHANGE# CORRUPTIO
----- ------ ------ ------------------ ---------
    5    131      1                  0 CORRUPT

LAX:(SYS@db01)>
LAX:(SYS@db01)> SELECT e.owner, e.segment_type, e.segment_name, e.partition_name, c.file#
  2         , greatest(e.block_id, c.block#) s_blk#
  3         , least(e.block_id+e.blocks-1, c.block#+c.blocks-1) e_dblk#
  4         , least(e.block_id+e.blocks-1, c.block#+c.blocks-1)
  5         - greatest(e.block_id, c.block#) + 1 blk_corrupt
  6        , null description
  7  FROM dba_extents e, v$database_block_corruption c
  8  WHERE e.file_id = c.file#
  9  AND e.block_id <= c.block# + c.blocks - 1  10  AND e.block_id + e.blocks - 1 >= c.block#
 11  UNION
 12  SELECT s.owner, s.segment_type, s.segment_name, s.partition_name, c.file#
 13         , header_block s_blk#
 14         , header_block e_blk#
 15         , 1 blk_corrupt
 16         , 'Segment Header' description
 17  FROM dba_segments s, v$database_block_corruption c
 18  WHERE s.header_file = c.file#
 19  AND s.header_block between c.block# and c.block# + c.blocks - 1
 20  UNION
 21  SELECT null owner, null segment_type, null segment_name, null partition_name, c.file#
 22         , greatest(f.block_id, c.block#) s_blk#
 23         , least(f.block_id+f.blocks-1, c.block#+c.blocks-1) e_blk#
 24         , least(f.block_id+f.blocks-1, c.block#+c.blocks-1)
 25         - greatest(f.block_id, c.block#) + 1 blk_corrupt
 26         , 'Free Block' description
 27  FROM dba_free_space f, v$database_block_corruption c
 28  WHERE f.file_id = c.file#
 29  AND f.block_id <= c.block# + c.blocks - 1  30  AND f.block_id + f.blocks - 1 >= c.block#
 31  order by file#, s_blk#
 32  ;

OWNER                SEGMENT_TYPE       SEGMENT_NAME              PARTITION_NAME            FILE# S_BLK#    E_DBLK# BLK_CORRUPT DESCRIPTION
-------------------- ------------------ ------------------------- ------------------------- ----- ------ ---------- ----------- --------------
                                                                                                5    131        131           1 Free Block

LAX:(SYS@db01)>
LAX:(SYS@db01)> exec SYS.DBMS_BACKUP_RESTORE.resetCfileSection(35);

PL/SQL procedure successfully completed.

LAX:(SYS@db01)> @corrupt_seg.sql
LAX:(SYS@db01)> set lines 200 pages 10000 echo on
LAX:(SYS@db01)> col OWNER for a20
LAX:(SYS@db01)> col FILE# for 999
LAX:(SYS@db01)> col BLOCK# for 99999
LAX:(SYS@db01)> col BLOCKS for 99999
LAX:(SYS@db01)> col s_blk# for 99999
LAX:(SYS@db01)> col e_blk# for 99999
LAX:(SYS@db01)> col CORRUPTION_CHANGE# for 999999999999
LAX:(SYS@db01)> col SEGMENT_NAME for a25
LAX:(SYS@db01)> col PARTITION_NAME for a25
LAX:(SYS@db01)> select instance_name from v$instance
  2  ;

INSTANCE_NAME
----------------
db01

LAX:(SYS@db01)> select * from v$database_block_corruption order by 1,2,3,4
  2  ;

no rows selected

LAX:(SYS@db01)>
LAX:(SYS@db01)> SELECT e.owner, e.segment_type, e.segment_name, e.partition_name, c.file#
  2         , greatest(e.block_id, c.block#) s_blk#
  3         , least(e.block_id+e.blocks-1, c.block#+c.blocks-1) e_dblk#
  4         , least(e.block_id+e.blocks-1, c.block#+c.blocks-1)
  5         - greatest(e.block_id, c.block#) + 1 blk_corrupt
  6        , null description
  7  FROM dba_extents e, v$database_block_corruption c
  8  WHERE e.file_id = c.file#
  9  AND e.block_id <= c.block# + c.blocks - 1  10  AND e.block_id + e.blocks - 1 >= c.block#
 11  UNION
 12  SELECT s.owner, s.segment_type, s.segment_name, s.partition_name, c.file#
 13         , header_block s_blk#
 14         , header_block e_blk#
 15         , 1 blk_corrupt
 16         , 'Segment Header' description
 17  FROM dba_segments s, v$database_block_corruption c
 18  WHERE s.header_file = c.file#
 19  AND s.header_block between c.block# and c.block# + c.blocks - 1
 20  UNION
 21  SELECT null owner, null segment_type, null segment_name, null partition_name, c.file#
 22         , greatest(f.block_id, c.block#) s_blk#
 23         , least(f.block_id+f.blocks-1, c.block#+c.blocks-1) e_blk#
 24         , least(f.block_id+f.blocks-1, c.block#+c.blocks-1)
 25         - greatest(f.block_id, c.block#) + 1 blk_corrupt
 26         , 'Free Block' description
 27  FROM dba_free_space f, v$database_block_corruption c
 28  WHERE f.file_id = c.file#
 29  AND f.block_id <= c.block# + c.blocks - 1  30  AND f.block_id + f.blocks - 1 >= c.block#
 31  order by file#, s_blk#
 32  ;

no rows selected

LAX:(SYS@db01)>
LAX:(SYS@db01)>

RMAN> validate tablespace corrupt;

Starting validate at 29-OCT-2013 22:51:54
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=33 device type=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: SID=16 device type=DISK
channel ORA_DISK_1: starting validation of datafile
channel ORA_DISK_1: specifying datafile(s) for validation
input datafile file number=00005 name=/oracle/datafilecopy/LAX_DB01/datafile/o1_mf_corrupt_97177krz_.dbf
channel ORA_DISK_1: validation complete, elapsed time: 00:00:03
List of Datafiles
=================

File Status Marked Corrupt Empty Blocks Blocks Examined High SCN
---- ------ -------------- ------------ --------------- ----------
5    FAILED 0              1917         2048            1833264
  File Name: /oracle/datafilecopy/LAX_DB01/datafile/o1_mf_corrupt_97177krz_.dbf
  Block Type Blocks Failing Blocks Processed
  ---------- -------------- ----------------
  Data       0              0
  Index      0              0
  Other      1              131

validate found one or more corrupt blocks

See trace file /u01/app/oracle/diag/rdbms/lax_db01/db01/trace/db01_ora_3382.trc for details
Finished validate at 29-OCT-2013 22:51:58

RMAN>

LAX:(SYS@db01)> @corrupt_seg.sql
LAX:(SYS@db01)> col OWNER for a20
LAX:(SYS@db01)> col FILE# for 999
LAX:(SYS@db01)> col BLOCK# for 99999
LAX:(SYS@db01)> col BLOCKS for 99999
LAX:(SYS@db01)> col s_blk# for 99999
LAX:(SYS@db01)> col e_blk# for 99999
LAX:(SYS@db01)> col CORRUPTION_CHANGE# for 999999999999
LAX:(SYS@db01)> col SEGMENT_NAME for a25
LAX:(SYS@db01)> col PARTITION_NAME for a25
LAX:(SYS@db01)> select instance_name from v$instance
  2  ;

INSTANCE_NAME
----------------
db01

LAX:(SYS@db01)> select * from v$database_block_corruption order by 1,2,3,4
  2  ;

FILE# BLOCK# BLOCKS CORRUPTION_CHANGE# CORRUPTIO
----- ------ ------ ------------------ ---------
    5    131      1                  0 CORRUPT

LAX:(SYS@db01)>
LAX:(SYS@db01)> SELECT e.owner, e.segment_type, e.segment_name, e.partition_name, c.file#
  2         , greatest(e.block_id, c.block#) s_blk#
  3         , least(e.block_id+e.blocks-1, c.block#+c.blocks-1) e_dblk#
  4         , least(e.block_id+e.blocks-1, c.block#+c.blocks-1)
  5         - greatest(e.block_id, c.block#) + 1 blk_corrupt
  6        , null description
  7  FROM dba_extents e, v$database_block_corruption c
  8  WHERE e.file_id = c.file#
  9  AND e.block_id <= c.block# + c.blocks - 1  10  AND e.block_id + e.blocks - 1 >= c.block#
 11  UNION
 12  SELECT s.owner, s.segment_type, s.segment_name, s.partition_name, c.file#
 13         , header_block s_blk#
 14         , header_block e_blk#
 15         , 1 blk_corrupt
 16         , 'Segment Header' description
 17  FROM dba_segments s, v$database_block_corruption c
 18  WHERE s.header_file = c.file#
 19  AND s.header_block between c.block# and c.block# + c.blocks - 1
 20  UNION
 21  SELECT null owner, null segment_type, null segment_name, null partition_name, c.file#
 22         , greatest(f.block_id, c.block#) s_blk#
 23         , least(f.block_id+f.blocks-1, c.block#+c.blocks-1) e_blk#
 24         , least(f.block_id+f.blocks-1, c.block#+c.blocks-1)
 25         - greatest(f.block_id, c.block#) + 1 blk_corrupt
 26         , 'Free Block' description
 27  FROM dba_free_space f, v$database_block_corruption c
 28  WHERE f.file_id = c.file#
 29  AND f.block_id <= c.block# + c.blocks - 1  30  AND f.block_id + f.blocks - 1 >= c.block#
 31  order by file#, s_blk#
 32  ;

OWNER                SEGMENT_TYPE       SEGMENT_NAME              PARTITION_NAME            FILE# S_BLK#    E_DBLK# BLK_CORRUPT DESCRIPTION
-------------------- ------------------ ------------------------- ------------------------- ----- ------ ---------- ----------- --------------
                                                                                                5    131        131           1 Free Block

LAX:(SYS@db01)>
LAX:(SYS@db01)>

Update:

Team mate has suggested the following article:

How to Clean entries from V$DATABASE_BLOCK_CORRUPTION when listing file/block corruption for a Datafile/Tablespace that was already dropped (Doc ID 1484189.1)

Following the note above to perform backup check logical does not solve the issue.

RMAN> backup check logical validate tablespace corrupt;

Starting backup at 30-OCT-2013 06:55:09
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=34 device type=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: SID=30 device type=DISK
channel ORA_DISK_1: starting compressed full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00005 name=/oracle/datafilecopy/LAX_DB01/datafile/o1_mf_corrupt_97177krz_.dbf
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
List of Datafiles
=================
File Status Marked Corrupt Empty Blocks Blocks Examined High SCN
---- ------ -------------- ------------ --------------- ----------
5    FAILED 0              1917         2048            1833264
  File Name: /oracle/datafilecopy/LAX_DB01/datafile/o1_mf_corrupt_97177krz_.dbf
  Block Type Blocks Failing Blocks Processed
  ---------- -------------- ----------------
  Data       0              0
  Index      0              0
  Other      1              131

validate found one or more corrupt blocks
See trace file /u01/app/oracle/diag/rdbms/lax_db01/db01/trace/db01_ora_2183.trc for details
Finished backup at 30-OCT-2013 06:55:13

RMAN> backup check logical validate datafile 5;

Starting backup at 30-OCT-2013 06:55:37
using channel ORA_DISK_1
using channel ORA_DISK_2
channel ORA_DISK_1: starting compressed full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00005 name=/oracle/datafilecopy/LAX_DB01/datafile/o1_mf_corrupt_97177krz_.dbf
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
List of Datafiles
=================
File Status Marked Corrupt Empty Blocks Blocks Examined High SCN
---- ------ -------------- ------------ --------------- ----------
5    FAILED 0              1917         2048            1833264
  File Name: /oracle/datafilecopy/LAX_DB01/datafile/o1_mf_corrupt_97177krz_.dbf
  Block Type Blocks Failing Blocks Processed
  ---------- -------------- ----------------
  Data       0              0
  Index      0              0
  Other      1              131

validate found one or more corrupt blocks
See trace file /u01/app/oracle/diag/rdbms/lax_db01/db01/trace/db01_ora_2183.trc for details
Finished backup at 30-OCT-2013 06:55:40

RMAN>

LAX:(SYS@db01)> set lines 200 pages 10000 echo on
LAX:(SYS@db01)> col OWNER for a20
LAX:(SYS@db01)> col FILE# for 999
LAX:(SYS@db01)> col BLOCK# for 99999
LAX:(SYS@db01)> col BLOCKS for 99999
LAX:(SYS@db01)> col s_blk# for 99999
LAX:(SYS@db01)> col e_blk# for 99999
LAX:(SYS@db01)> col CORRUPTION_CHANGE# for 999999999999
LAX:(SYS@db01)> col SEGMENT_NAME for a25
LAX:(SYS@db01)> col PARTITION_NAME for a25
LAX:(SYS@db01)> select instance_name from v$instance
  2  ;

INSTANCE_NAME
----------------
db01

LAX:(SYS@db01)> select * from v$database_block_corruption order by 1,2,3,4
  2  ;

FILE# BLOCK# BLOCKS CORRUPTION_CHANGE# CORRUPTIO
----- ------ ------ ------------------ ---------
    5    131      1                  0 CORRUPT

LAX:(SYS@db01)>
LAX:(SYS@db01)> SELECT e.owner, e.segment_type, e.segment_name, e.partition_name, c.file#
  2         , greatest(e.block_id, c.block#) s_blk#
  3         , least(e.block_id+e.blocks-1, c.block#+c.blocks-1) e_dblk#
  4         , least(e.block_id+e.blocks-1, c.block#+c.blocks-1)
  5         - greatest(e.block_id, c.block#) + 1 blk_corrupt
  6        , null description
  7  FROM dba_extents e, v$database_block_corruption c
  8  WHERE e.file_id = c.file#
  9  AND e.block_id <= c.block# + c.blocks - 1  10  AND e.block_id + e.blocks - 1 >= c.block#
 11  UNION
 12  SELECT s.owner, s.segment_type, s.segment_name, s.partition_name, c.file#
 13         , header_block s_blk#
 14         , header_block e_blk#
 15         , 1 blk_corrupt
 16         , 'Segment Header' description
 17  FROM dba_segments s, v$database_block_corruption c
 18  WHERE s.header_file = c.file#
 19  AND s.header_block between c.block# and c.block# + c.blocks - 1
 20  UNION
 21  SELECT null owner, null segment_type, null segment_name, null partition_name, c.file#
 22         , greatest(f.block_id, c.block#) s_blk#
 23         , least(f.block_id+f.blocks-1, c.block#+c.blocks-1) e_blk#
 24         , least(f.block_id+f.blocks-1, c.block#+c.blocks-1)
 25         - greatest(f.block_id, c.block#) + 1 blk_corrupt
 26         , 'Free Block' description
 27  FROM dba_free_space f, v$database_block_corruption c
 28  WHERE f.file_id = c.file#
 29  AND f.block_id <= c.block# + c.blocks - 1  30  AND f.block_id + f.blocks - 1 >= c.block#
 31  order by file#, s_blk#
 32  ;

OWNER                SEGMENT_TYPE       SEGMENT_NAME              PARTITION_NAME            FILE# S_BLK#    E_DBLK# BLK_CORRUPT DESCRIPTION
-------------------- ------------------ ------------------------- ------------------------- ----- ------ ---------- ----------- --------------
                                                                                                5    131        131           1 Free Block

LAX:(SYS@db01)> drop tablespace corrupt including contents and datafiles;

Tablespace dropped.

LAX:(SYS@db01)> @corrupt_seg.sql
LAX:(SYS@db01)> set lines 200 pages 10000 echo on
LAX:(SYS@db01)> col OWNER for a20
LAX:(SYS@db01)> col FILE# for 999
LAX:(SYS@db01)> col BLOCK# for 99999
LAX:(SYS@db01)> col BLOCKS for 99999
LAX:(SYS@db01)> col s_blk# for 99999
LAX:(SYS@db01)> col e_blk# for 99999
LAX:(SYS@db01)> col CORRUPTION_CHANGE# for 999999999999
LAX:(SYS@db01)> col SEGMENT_NAME for a25
LAX:(SYS@db01)> col PARTITION_NAME for a25
LAX:(SYS@db01)> select instance_name from v$instance
  2  ;

INSTANCE_NAME
----------------
db01

LAX:(SYS@db01)> select * from v$database_block_corruption order by 1,2,3,4
  2  ;

no rows selected

LAX:(SYS@db01)>

Does anyone have or know of a short cut for this?

SOLVED:

I am getting good at corrupting data.

OWNER                SEGMENT_TYPE       SEGMENT_NAME              PARTITION_NAME            FILE# S_BLK#    E_DBLK# BLK_CORRUPT DESCRIPTION
-------------------- ------------------ ------------------------- ------------------------- ----- ------ ---------- ----------- --------------
                                                                                                5    827        827           1 Free Block
                                                                                                5    835        835           1 Free Block

LAX:(SYS@db01)>
LAX:(SYS@db01)> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@lax:db01]/home/oracle
$ rman target /

Recovery Manager: Release 11.2.0.3.0 - Production on Wed Oct 30 07:34:39 2013

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

connected to target database: DB01 (DBID=1452485914)

RMAN> validate tablespace corrupt;

Starting validate at 30-OCT-2013 07:34:50
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=42 device type=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: SID=44 device type=DISK
channel ORA_DISK_1: starting validation of datafile
channel ORA_DISK_1: specifying datafile(s) for validation
input datafile file number=00005 name=/oracle/datafilecopy/LAX_DB01/datafile/o1_mf_corrupt_97261fmr_.dbf
channel ORA_DISK_1: validation complete, elapsed time: 00:00:03
List of Datafiles
=================
File Status Marked Corrupt Empty Blocks Blocks Examined High SCN
---- ------ -------------- ------------ --------------- ----------
5    FAILED 0              1915         2048            1859108
  File Name: /oracle/datafilecopy/LAX_DB01/datafile/o1_mf_corrupt_97261fmr_.dbf
  Block Type Blocks Failing Blocks Processed
  ---------- -------------- ----------------
  Data       0              0
  Index      0              1
  Other      2              132

validate found one or more corrupt blocks
See trace file /u01/app/oracle/diag/rdbms/lax_db01/db01/trace/db01_ora_2608.trc for details
Finished validate at 30-OCT-2013 07:34:54

RMAN> list backup summary;

specification does not match any backup in the repository

RMAN> backup check logical tablespace corrupt;

Starting backup at 30-OCT-2013 07:35:48
using channel ORA_DISK_1
using channel ORA_DISK_2
channel ORA_DISK_1: starting compressed full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00005 name=/oracle/datafilecopy/LAX_DB01/datafile/o1_mf_corrupt_97261fmr_.dbf
channel ORA_DISK_1: starting piece 1 at 30-OCT-2013 07:35:49
channel ORA_DISK_1: finished piece 1 at 30-OCT-2013 07:35:52
piece handle=/oracle/backup/bkup_8qonmdml_1_1 tag=TAG20131030T073548 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
Finished backup at 30-OCT-2013 07:35:52

Starting Control File and SPFILE Autobackup at 30-OCT-2013 07:35:52
piece handle=/oracle/flashrecovery/LAX_DB01/autobackup/2013_10_30/o1_mf_s_830158552_9726bdgf_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 30-OCT-2013 07:35:59

RMAN> blockrecover datafile 5 block 827,835;

Starting recover at 30-OCT-2013 07:39:09
using channel ORA_DISK_1
using channel ORA_DISK_2

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 /oracle/backup/bkup_8qonmdml_1_1
channel ORA_DISK_1: piece handle=/oracle/backup/bkup_8qonmdml_1_1 tag=TAG20131030T073548
channel ORA_DISK_1: restored block(s) from backup piece 1
channel ORA_DISK_1: block restore complete, elapsed time: 00:00:01

starting media recovery
media recovery complete, elapsed time: 00:00:04

Finished recover at 30-OCT-2013 07:39:17

RMAN> validate tablespace corrupt;

Starting validate at 30-OCT-2013 07:39:25
using channel ORA_DISK_1
using channel ORA_DISK_2
channel ORA_DISK_1: starting validation of datafile
channel ORA_DISK_1: specifying datafile(s) for validation
input datafile file number=00005 name=/oracle/datafilecopy/LAX_DB01/datafile/o1_mf_corrupt_97261fmr_.dbf
channel ORA_DISK_1: validation complete, elapsed time: 00:00:01
List of Datafiles
=================
File Status Marked Corrupt Empty Blocks Blocks Examined High SCN
---- ------ -------------- ------------ --------------- ----------
5    OK     0              1915         2050            1859108
  File Name: /oracle/datafilecopy/LAX_DB01/datafile/o1_mf_corrupt_97261fmr_.dbf
  Block Type Blocks Failing Blocks Processed
  ---------- -------------- ----------------
  Data       0              0
  Index      0              1
  Other      0              132

Finished validate at 30-OCT-2013 07:39:27

RMAN> exit

Recovery Manager complete.
[oracle@lax:db01]/home/oracle
$

New Rman Blockrecover command in 11g (Recover corruption list) (Doc ID 1390759.1)

Note: For 11g, recover corruption list can be used to recovery all corruption versus listing them one by one.

I am not sure if blockrecover corruption list would have worked on 10g as well. May be you can try it and let me know?

RMAN> recover corruption list;

Starting recover at 30-OCT-2013 07:22:56
using channel ORA_DISK_1
using channel ORA_DISK_2

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 /oracle/backup/bkup_4gonmcsj_1_1
channel ORA_DISK_1: piece handle=/oracle/backup/bkup_4gonmcsj_1_1 tag=TAG20131030T072154
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 30-OCT-2013 07:23:09

RMAN> validate tablespace corrupt;

Starting validate at 30-OCT-2013 07:23:20
using channel ORA_DISK_1
using channel ORA_DISK_2
channel ORA_DISK_1: starting validation of datafile
channel ORA_DISK_1: specifying datafile(s) for validation
input datafile file number=00005 name=/oracle/datafilecopy/LAX_DB01/datafile/o1_mf_corrupt_9724xr04_.dbf
channel ORA_DISK_1: validation complete, elapsed time: 00:00:01
List of Datafiles
=================
File Status Marked Corrupt Empty Blocks Blocks Examined High SCN
—- —— ————– ———— ————— ———-
5 OK 0 1916 2050 1856947
File Name: /oracle/datafilecopy/LAX_DB01/datafile/o1_mf_corrupt_9724xr04_.dbf
Block Type Blocks Failing Blocks Processed
———- ————– —————-
Data 0 0
Index 0 0
Other 0 132

Finished validate at 30-OCT-2013 07:23:22

RMAN>



Viewing all articles
Browse latest Browse all 666

Trending Articles