love wife & love life —Roger的Oracle&MySQL技术博客

Phone:18180207355 提供专业Oracle&MySQL数据恢复、性能优化、迁移升级、紧急救援等服务

bootstrap$核心对象数据不一致导致ORA-08102

本站文章除注明转载外,均为本站原创: 转载自love wife & love life —Roger的Oracle&MySQL技术博客

本文链接地址: bootstrap$核心对象数据不一致导致ORA-08102

昨天准备研究11g的query cache result 特性,准备用10g的老方法来直接通过
show parameter xxxx的方式来查看隐含参数,发现下面的创建视图语句居然报错ora-08102
如下是创建视图的脚本,后面是错误:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
CREATE OR REPLACE VIEW show_hidden_v$parameter (inst_id,
                                                num,
                                                NAME,
                                                TYPE,
                                                VALUE,
                                                display_value,
                                                isdefault,
                                                isses_modifiable,
                                                issys_modifiable,
                                                isinstance_modifiable,
                                                ismodified,
                                                isadjusted,
                                                isdeprecated,
                                                description,
                                                update_comment,
                                                HASH
                                               )
AS
   SELECT x.inst_id, x.indx + 1, ksppinm, ksppity, ksppstvl, ksppstdvl,
          ksppstdf, DECODE (BITAND (ksppiflg / 256, 1), 1, 'TRUE', 'FALSE'),
          DECODE (BITAND (ksppiflg / 65536, 3),
                  1, 'IMMEDIATE',
                  2, 'DEFERRED',
                  3, 'IMMEDIATE',
                  'FALSE'
                 ),
          DECODE (BITAND (ksppiflg, 4),
                  4, 'FALSE',
                  DECODE (BITAND (ksppiflg / 65536, 3), 0, 'FALSE', 'TRUE')
                 ),
          DECODE (BITAND (ksppstvf, 7),
                  1, 'MODIFIED',
                  4, 'SYSTEM_MOD',
                  'FALSE'
                 ),
          DECODE (BITAND (ksppstvf, 2), 2, 'TRUE', 'FALSE'),
          DECODE (BITAND (ksppilrmflg / 64, 1), 1, 'TRUE', 'FALSE'), ksppdesc,
          ksppstcmnt, ksppihash
     FROM x$ksppi x, x$ksppcv y
    WHERE (x.indx = y.indx);
ORA-08102: index key not found, obj# 39, file 1, block 59847 (2)


从上面的8102错误来看,很明显是数据字典信息不一致了,也就是说该记录在ind$可能已经被清除了,
而在obj$中还存在。我们来看看obj# 39是什么对象?

SQL> SELECT relative_fno, owner, segment_name, segment_type
  2  FROM dba_extents
  3  WHERE file_id = 1
  4  AND 59847 BETWEEN block_id AND block_id + blocks - 1;
 
RELATIVE_FNO OWNER   SEGMENT_NAME                   SEGMENT_TYPE
------------ ------- ------------------------------ ------------------
           1 SYS     I_OBJ4                         INDEX
 
SQL> SELECT owner,object_name,object_type,object_id FROM                                                               
  2  dba_objects WHERE object_name='I_OBJ4';                                                                           
 
OWNER                OBJECT_NAME               OBJECT_TYPE          OBJECT_ID                                          
-------------------- ------------------------- ------------------- ----------                                          
SYS                  I_OBJ4                    INDEX                       39


对于ora-08102错误,如果是发生在index上,那么我们直接drop index然后重建就ok了。
那我们来试试直接重建会怎么样?

SQL> ALTER system SET event='38003 trace name context forever, level 10' scope=spfile;
System altered.
 
SQL> shutdown immediate;
DATABASE closed.
DATABASE dismounted.
ORACLE instance shut down.
 
SQL> startup
 
ORACLE instance started.
Total System Global Area  167395328 bytes
Fixed SIZE                  1335220 bytes
Variable SIZE             104857676 bytes
DATABASE Buffers           58720256 bytes
Redo Buffers                2482176 bytes
DATABASE mounted.
DATABASE opened.
 
SQL> ALTER INDEX I_OBJ4 rebuild;
ALTER INDEX I_OBJ4 rebuild
*
ERROR at line 1:
ORA-00604: error occurred at recursive SQL level 1
ORA-00060: deadlock detected while waiting FOR resource
 
SQL> shutdown abort;
ORACLE instance shut down.
 
SQL> startup migrate;
 
ORACLE instance started.
Total System Global Area  167395328 bytes
Fixed SIZE                  1335220 bytes
Variable SIZE             104857676 bytes
DATABASE Buffers           58720256 bytes
Redo Buffers                2482176 bytes
DATABASE mounted.
DATABASE opened.
 
SQL> ALTER INDEX I_OBJ4 rebuild;
ALTER INDEX I_OBJ4 rebuild
*
ERROR at line 1:
ORA-00604: error occurred at recursive SQL level 1
ORA-00060: deadlock detected while waiting FOR resource
 
SQL> DROP INDEX I_OBJ4;
DROP INDEX I_OBJ4
           *
ERROR at line 1:
ORA-00701: object necessary FOR warmstarting DATABASE cannot be altered  
 
SQL> ALTER INDEX I_OBJ4 rebuild online;
ALTER INDEX I_OBJ4 rebuild online
*
ERROR at line 1:
ORA-00604: error occurred at recursive SQL level 1
ORA-08102: INDEX KEY NOT found, obj# 39, file 1, block 59847 (2)
 
SQL> analyze TABLE obj$ VALIDATE STRUCTURE CASCADE;
analyze TABLE obj$ VALIDATE STRUCTURE CASCADE
*
ERROR at line 1:
ORA-01499: TABLE/INDEX CROSS reference failure - see trace file


到这里,可能有人会问,为什么使用event 38003或migrate 模式无法rebuild 该index呢?
很简单,该index的obj# <56, 换句话说,也就是对于bootstrap$核心对象是无法通过上面 的2种方式来完成重建的。

通常来说到这个地步,如果不使用其他手段的话,那么只能使用ODU或DUL进行抽取数据然后重建数据库了。
其实对于这个问题,我们可以借助BBED来进行修复。
既然是数据不一致,那么我就想知道到底是哪儿不一致了?metalink 提供处理ora-8102的方法:

SQL> SELECT /*+ FULL(t1) */ DATAOBJ#, TYPE#, OWNER#, rowid
  2  FROM obj$ t1
  3  MINUS
  4  SELECT /*+ index(t I_OBJ4) */ DATAOBJ#, TYPE#, OWNER#, rowid
  5  FROM obj$ t;
 
  DATAOBJ#      TYPE#     OWNER# ROWID
---------- ---------- ---------- ------------------
     73416          2          0 AAAAASAABAAAPt8AAB
     73419          0          0 AAAAASAABAAAADxAAb
 
SQL> SELECT obj#,OWNER#,NAME,TYPE#,STATUS,FLAGS FROM obj$ WHERE rowid='AAAAASAABAAAPt8AAB';
 
      OBJ#     OWNER# NAME                                TYPE#     STATUS      FLAGS
---------- ---------- ------------------------------ ---------- ---------- ----------
     73416          0 TEST01                                  2          1          0
 
SQL> SELECT obj#,OWNER#,NAME,TYPE#,STATUS,FLAGS FROM obj$ WHERE rowid='AAAAASAABAAAADxAAb';
 
      OBJ#     OWNER# NAME                                TYPE#     STATUS      FLAGS
---------- ---------- ------------------------------ ---------- ---------- ----------
         1          0 _NEXT_OBJECT                            0          0          0
 
SQL> SELECT CASE
  2            WHEN (nextobjnum - maxobjnum) > 0
  3               THEN 'GOOD'
  4            ELSE 'BAD'
  5         END "OBJ_NUM_STATE"
  6    FROM (SELECT (SELECT dataobj#
  7                    FROM SYS.obj$
  8                   WHERE NAME = '_NEXT_OBJECT') nextobjnum,
  9                 (SELECT MAX (obj#)
 10                    FROM SYS.obj$) maxobjnum
 11          FROM DUAL);
 
 
OBJ_
----
GOOD

从这里来看,_NEXT_OBJECT是ok的。那么我们重点就放在TEST01上了。
到这里,看到test01,我才想起这是很久以前做关于手工构造某个由于数据字典信息不一致而引发的某个600错误
而留下的隐患。

根据前面的报错,我们找到相应的trace,发现如下信息:

oer 8102.2 - obj# 39, rdba: 0x0040e9c7(afn 1, blk# 59847)
kdk key 8102.2:
  ncol: 4, len: 16
  key: (16):  04 c3 08 23 14 01 80 01 80 06 00 40 00 f1 00 1b
  mask: (2048):


这里简单的进行说明:
ncol — 表示列数目
len — 表示长度
key: ():

关于ora-08012错误,大家可以参考

OERR: ORA-8102 “index key not found, obj# %s, file %s, block %s (%s)” [ID 8102.1]

下面我们继续,既然该block有问题,那么我就dump该block。

SQL> ALTER system dump datafile 1 block 59847;
 
确定为如下2行数据:
 
ROW#131[2131] flag: ---D--, lock: 3, len=18
col 0; len 4; (4):  c3 08 23 0a
col 1; len 1; (1):  80
col 2; len 1; (1):  80
col 3; len 6; (6):  00 40 00 f1 00 1b
 
ROW#133[2113] flag: ------, lock: 3, len=18
col 0; len 4; (4):  c3 08 23 0f
col 1; len 1; (1):  80
col 2; len 1; (1):  80
col 3; len 6; (6):  00 40 00 f1 00 1b
 
SQL> SELECT 2131+44+24*3 FROM dual;
 
2131+44+24*3
------------
        2247
BBED> set file 1 block 59847
 
        FILE#           1
        BLOCK#          59847
 
BBED> set offset 2247
 
        OFFSET          2247
 
BBED> d /v
 
 File: /oracle/product/oradata/roger/system01.dbf (1)
 Block: 59847   Offsets: 2247 to 2758  Dba:0x0040e9c7
-------------------------------------------------------
 010304c3 08230a01 80018006 004000f1 l .....#.......@..
 001b0000 04c30823 0202c102 01800600 l .......#........
 40fb7c00 1a010003 c3082302 c1020180 l @.|.......#.....
 060040fb 7c001b00 0004c308 226402c1 l ..@.|......."d..
 03018006 00402750 00090100 04c30822 l .....@'P......."
 6202c102 01800600 40fb7c00 1a010004 l b.......@.|.....
 c3082263 02c10201 80060040 fb7c001c l .."c.......@.|..
 010004c3 08230501 80018006 004000f1 l .....#.......@..
 001b0100 04c30822 6002c102 01800600 l ......."`.......
 40fb7c00 1a010004 c3082264 01800180 l @.|......."d....
 06004000 f1001b01 0004c308 225e02c1 l ..@........."^..
 02018006 0040fb7c 001c0100 04c30822 l .....@.|......."
 5d02c102 01800600 40fb7c00 1b010004 l ].......@.|.....
 c308225b 02c10201 80060040 fb7c001c l .."[.......@.|..
 010004c3 08225a02 c1020180 060040fb l ....."Z.......@.
 7c001a01 0004c308 225f0180 01800600 l |......."_......
 4000f100 1b010004 c3082256 02c11501 l @........."V....
 80060040 fb7c0019 000004c3 08225702 l ...@.|......."W.
 c1150180 060040fb 7c001801 0004c308 l ......@.|.......
 225502c1 14018006 0040fb7b 000f0000 l "U.......@.{....
 04c30822 5402c114 01800600 40fb7c00 l ..."T.......@.|.
 17010004 c308225a 01800180 06004000 l ......"Z......@.
 f1001b01 0004c308 225202c1 15018006 l ........"R......
 0040fb7c 00160000 04c30822 5302c115 l .@.|......."S...
 01800600 40fb7c00 15010004 c3082251 l ....@.|......."Q
 02c11401 80060040 fb7b000c 000004c3 l .......@.{......
 08225002 c1140180 060040fb 7c001401 l ."P.......@.|...
 0004c308 22550180 01800600 4000f100 l ...."U......@...
 1b010004 c308224e 02c11501 80060040 l ......"N.......@
 fb7c0013 000004c3 08224f02 c1150180 l .|......."O.....
 060040fb 7c001201 0004c308 224d02c1 l ..@.|......."M..
 14018006 0040fb7b 00090000 04c30822 l .....@.{......."
 
 <16 bytes per line>
 
BBED> modify /x 14 offset 2253
 
 File: /oracle/product/oradata/roger/system01.dbf (1)
 Block: 59847            Offsets: 2253 to 2764           Dba:0x0040e9c7
------------------------------------------------------------------------
 14018001 80060040 00f1001b 000004c3 08230202 c1020180 060040fb 7c001a01
 0003c308 2302c102 01800600 40fb7c00 1b000004 c3082264 02c10301 80060040
 27500009 010004c3 08226202 c1020180 060040fb 7c001a01 0004c308 226302c1
 02018006 0040fb7c 001c0100 04c30823 05018001 80060040 00f1001b 010004c3
 08226002 c1020180 060040fb 7c001a01 0004c308 22640180 01800600 4000f100
 1b010004 c308225e 02c10201 80060040 fb7c001c 010004c3 08225d02 c1020180
 060040fb 7c001b01 0004c308 225b02c1 02018006 0040fb7c 001c0100 04c30822
 5a02c102 01800600 40fb7c00 1a010004 c308225f 01800180 06004000 f1001b01
 0004c308 225602c1 15018006 0040fb7c 00190000 04c30822 5702c115 01800600
 40fb7c00 18010004 c3082255 02c11401 80060040 fb7b000f 000004c3 08225402
 c1140180 060040fb 7c001701 0004c308 225a0180 01800600 4000f100 1b010004
 c3082252 02c11501 80060040 fb7c0016 000004c3 08225302 c1150180 060040fb
 7c001501 0004c308 225102c1 14018006 0040fb7b 000c0000 04c30822 5002c114
 01800600 40fb7c00 14010004 c3082255 01800180 06004000 f1001b01 0004c308
 224e02c1 15018006 0040fb7c 00130000 04c30822 4f02c115 01800600 40fb7c00
 12010004 c308224d 02c11401 80060040 fb7b0009 000004c3 08224c02 c1140180
 
 <32 bytes per line>
 
BBED> sum apply
 
Check value for File 1, Block 59847:
current = 0xe5a9, required = 0xe5a9
BBED> modify /x 14 offset 2235
 File: /oracle/product/oradata/roger/system01.dbf (1)
 Block: 59847            Offsets: 2235 to 2746           Dba:0x0040e9c7
------------------------------------------------------------------------
 14018001 80060040 00f1001b 010304c3 08231401 80018006 004000f1 001b0000
 04c30823 0202c102 01800600 40fb7c00 1a010003 c3082302 c1020180 060040fb
 7c001b00 0004c308 226402c1 03018006 00402750 00090100 04c30822 6202c102
 01800600 40fb7c00 1a010004 c3082263 02c10201 80060040 fb7c001c 010004c3
 08230501 80018006 004000f1 001b0100 04c30822 6002c102 01800600 40fb7c00
 1a010004 c3082264 01800180 06004000 f1001b01 0004c308 225e02c1 02018006
 0040fb7c 001c0100 04c30822 5d02c102 01800600 40fb7c00 1b010004 c308225b
 02c10201 80060040 fb7c001c 010004c3 08225a02 c1020180 060040fb 7c001a01
 0004c308 225f0180 01800600 4000f100 1b010004 c3082256 02c11501 80060040
 fb7c0019 000004c3 08225702 c1150180 060040fb 7c001801 0004c308 225502c1
 14018006 0040fb7b 000f0000 04c30822 5402c114 01800600 40fb7c00 17010004
 c308225a 01800180 06004000 f1001b01 0004c308 225202c1 15018006 0040fb7c
 00160000 04c30822 5302c115 01800600 40fb7c00 15010004 c3082251 02c11401
 80060040 fb7b000c 000004c3 08225002 c1140180 060040fb 7c001401 0004c308
 22550180 01800600 4000f100 1b010004 c308224e 02c11501 80060040 fb7c0013
 000004c3 08224f02 c1150180 060040fb 7c001201 0004c308 224d02c1 14018006
 
 <32 bytes per line>
 
BBED> sum apply
 
Check value for File 1, Block 59847:
current = 0xfea9, required = 0xfea9
 
BBED> verify
 
DBVERIFY - Verification starting
FILE = /oracle/product/oradata/roger/system01.dbf
BLOCK = 59847
 
Block Checking: DBA = 4254151, Block Type = KTB-managed data block
**** row 132: key out of order
---- end index block validation
Block 59847 failed with check code 6401
 
DBVERIFY - Verification complete
 
Total Blocks Examined         : 1
Total Blocks Processed (Data) : 0
Total Blocks Failing   (Data) : 0
Total Blocks Processed (Index): 1
Total Blocks Failing   (Index): 1
Total Blocks Empty            : 0
Total Blocks Marked Corrupt   : 0
Total Blocks Influx           : 0
Message 531 not found;  product=RDBMS; facility=BBED
 
最后重启后,创建成功,再次检查发现一切ok。
 
BBED> verify
 
DBVERIFY - Verification starting
FILE = /oracle/product/oradata/roger/system01.dbf
BLOCK = 59847
 
DBVERIFY - Verification complete
 
Total Blocks Examined         : 1
Total Blocks Processed (Data) : 0
Total Blocks Failing   (Data) : 0
Total Blocks Processed (Index): 1
Total Blocks Failing   (Index): 0
Total Blocks Empty            : 0
Total Blocks Marked Corrupt   : 0
Total Blocks Influx           : 0
Message 531 not found;  product=RDBMS; facility=BBED

最后尝试创建视图,发现一切正常,如下:

SQL> CREATE OR REPLACE VIEW show_hidden_v$parameter (inst_id,
  2                                                  num,
  3                                                  NAME,
  4                                                  TYPE,
  5                                                  VALUE,
  6                                                  display_value,
  7                                                  isdefault,
  8                                                  isses_modifiable,
  9                                                  issys_modifiable,
 10                                                  isinstance_modifiable,
 11                                                  ismodified,
 12                                                  isadjusted,
 13                                                  isdeprecated,
 14                                                  description,
 15                                                  update_comment,
 16                                                  HASH
 17                                                 )
 18  AS
 19     SELECT x.inst_id, x.indx + 1, ksppinm, ksppity, ksppstvl, ksppstdvl,
 20            ksppstdf, DECODE (BITAND (ksppiflg / 256, 1), 1, 'TRUE', 'FALSE'),
 21            DECODE (BITAND (ksppiflg / 65536, 3),
 22                    1, 'IMMEDIATE',
 23                    2, 'DEFERRED',
 24                    3, 'IMMEDIATE',
 25                    'FALSE'
 26                   ),
 27            DECODE (BITAND (ksppiflg, 4),
 28                    4, 'FALSE',
 29                    DECODE (BITAND (ksppiflg / 65536, 3), 0, 'FALSE', 'TRUE')
 30                   ),
 31            DECODE (BITAND (ksppstvf, 7),
 32                    1, 'MODIFIED',
 33                 4, 'SYSTEM_MOD',
 34                 'FALSE'
 35                ),
 36         DECODE (BITAND (ksppstvf, 2), 2, 'TRUE', 'FALSE'),
 37         DECODE (BITAND (ksppilrmflg / 64, 1), 1, 'TRUE', 'FALSE'), ksppdesc,
 38         ksppstcmnt, ksppihash
 39    FROM x$ksppi x, x$ksppcv y
 40   WHERE (x.indx = y.indx);
 
VIEW created.

10 Responses to “bootstrap$核心对象数据不一致导致ORA-08102”

  1. saints jerseys Says:

    There may be noticeably a bundle to know about this. I assume you made sure nice points in options also.

  2. Forex trading software Says:

    Lots of beneficial in a row. I give rise to bookmarked your place.

  3. Arnold Baldasaro Says:

    Good day! I just would like to offer you a huge thumbs up for your great info you have right here on this post. I will be returning to your website from my own http://how-to-break-up.tumblr.com for more soon.

  4. bootstrap$核心对象数据不一致导致ORA-08102 - Oracle - 开发者第994665个问答 Says:

    […] 原帖:http://www.killdb.com/?p=201   本文参考了dbsnake和老白的部分方法,再次感谢两位! […]

  5. hunt1574 Says:

    SELECT 2131+44+24*3 FROM dual;

    请问下这个44及24*3是怎么来的?

  6. xccheese Says:

    N+44+24*itl N是行数据的补偿 44是 kcbh(cache层)长度+ktbbh(事务层)长度 24是一个itl的长度 总共加起来其实就是行数据的offset

  7. hongfei Says:

    能否说明下modify /x 14 offset 2235 是怎么算出来的吗?

  8. yangjiawei Says:

    下面的兄弟你自己看一下,主要是ind$和obj$上对于这个索引的这个这个数据上的值不一样而已,呵呵~!

  9. How to recreate Bootstrap Index(I_OBJ1,I_USER1,I_FILE#_BLOCK#) to fix ORA-00701 ? | love wife & love life —Roger 的Oracle技术博客 Says:

    […] 几年前之前也写过一篇通过bbed来修复bootstrap 核心数据index创建时出现ora-08102错误的例子:bootstrap$核心对象数据不一致导致ORA-08102 […]

  10. desert_xu Says:

    2253-2247=6 ,需要修改 的数据 c3 08 23 0a => c3 08 23 14 ,即 把0a 改成 14 ,0a 的位置偏移量为 6

    2247 2248 2249 2250 2251 2252 2253

    01 03 04 c3 08 23 0a

Leave a Reply

You must be logged in to post a comment.