客户反应无法在生产环境创建物化视图,登录远程上去尝试创建后发现报错下面错误:
ORA-00604: error occurred at recursive SQL level 1
ORA-08102: index key not found, obj# 399205, file 36, block 200745 (2)
接下来看下8102是什么错误:
[oracle@rac01 ~]$ oerr ora 8102
08102, 00000, "index key not found, obj# %s, file %s, block %s (%s)"
// *Cause: Internal error: possible inconsistency in index
// *Action: Send trace file to your customer support representative, along
// with information on reproducing the error
并没有明确的解释8102的错误,这下只能从mos上获取信息了。在mos上搜索到了一篇文章8102.1:
OERR: ORA-8102 "index key not found, obj# %s, file %s, block %s (%s)" (Doc ID 8102.1)
错误描述:
ORA-8102的原因是表或者LOB segment存储的键值和索引不一致造成的,通过出错误中提示的obj#,可以在dba_objects中定位到对象,例如:
select * from dba_objects where object_id = 46115
如果在表和索引真的存在键值不一致,那么下面的分析表命令会报错ORA-1499
analyze table table_name validate structure cascade;
一种非主流的方法可以去查询出不一致的键值,index name是在dba_objects中查询出的索引
select /+ FULL(t1) / indexed_column_list
from table_name t1
minus
select /+ index(t ) / indexed_column_list
from table_name t;
引起ORA-8102的原因有以下几点:
1.Oracle defect:由bug引起
2.Block corruption in the index or in the table:索引或表的坏块
定位索引坏块
analyze index index_name validate structure;
定位表坏块
analyze table table_name validate structure;
3.Hardware / IO
4.Function-based indexes:函数索引
解决方案:
解决方案很简单,重建索引即可:
alter index index_name rebuild online;