视频1 视频21 视频41 视频61 视频文章1 视频文章21 视频文章41 视频文章61 推荐1 推荐3 推荐5 推荐7 推荐9 推荐11 推荐13 推荐15 推荐17 推荐19 推荐21 推荐23 推荐25 推荐27 推荐29 推荐31 推荐33 推荐35 推荐37 推荐39 推荐41 推荐43 推荐45 推荐47 推荐49 关键词1 关键词101 关键词201 关键词301 关键词401 关键词501 关键词601 关键词701 关键词801 关键词901 关键词1001 关键词1101 关键词1201 关键词1301 关键词1401 关键词1501 关键词1601 关键词1701 关键词1801 关键词1901 视频扩展1 视频扩展6 视频扩展11 视频扩展16 文章1 文章201 文章401 文章601 文章801 文章1001 资讯1 资讯501 资讯1001 资讯1501 标签1 标签501 标签1001 关键词1 关键词501 关键词1001 关键词1501 专题2001
onlineindexcreatefail引起ora-08104
2020-11-09 13:08:30 责编:小采
文档


由于系统负载较高,Online重建索引太慢,就直接kill掉该session,准备删除索引再进行重建,此时发觉无法对其进行删除和重建。 SQL> drop index call.ind_id; drop index call.ind_id * ERROR at line 1: ORA-08104: this index object 179685 is being onlin

由于系统负载较高,Online重建索引太慢,就直接kill掉该session,准备删除索引再进行重建,此时发觉无法对其进行删除和重建。
SQL> drop index call.ind_id;
drop index call.ind_id
*
ERROR at line 1:
ORA-08104: this index object 179685 is being online built or rebuilt

SQL> alter index call.ind_id rebuild;
alter index call.ind_id rebuild
*
ERROR at line 1:
ORA-08104: this index object 179685 is being online built or rebuilt

SQL> alter index call.ind_id rebuild online;
alter index call.ind_id rebuild online
*
ERROR at line 1:
ORA-08104: this index object 179685 is being online built or rebuilt

报出了ora-08104错误,找到mos上的几篇文章
Session Was Killed During The Rebuild Of Index ORA-08104 (文档 ID 375856.1)

CAUSE
A session failure during an online index rebuild can leave the data dictionary in a state reflecting a rebuild is ongoing when in fact it is not.

SOLUTION
The dbms_repair.online_index_clean function has been created to cleanup online index rebuilds. Use the dbms_repair.online_index_clean function to resolve the issue.
* Please note if you are unable to run the dbms_repair.online_index_clean function it is due to the fact that you have not installed the patch for Bug 3805539 or are not running on a release that includes this fix. The fix for this bug is a new function in the dbms_repair package called dbms_repair.online_index_clean, which has been created to cleanup online index [[sub]partition] [re]builds. New functionality is not normally introduced in patchsets; therefore, this is not available in a patchset but is available in 10gR2.
- Check your patch list to verify the database is patched for Bug 3805539 using the following command and patch for the bug if it is not listed:

opatch lsinventory -detail

造成这个现象的原因是因为数据字典信息和实际信息冲突,数据字典中记录的是索引在重建,但是事实并不是如此

下面小鱼手动模拟这个故障的始末:
SQL> create table tab01 as select * from dba_tab_col_statistics;

Table created.
SQL> insert into tab01 select * from tab01;

179626 rows created.

SQL> /

359252 rows created.

SQL> commit;

Commit complete.

SQL> select spid from v$process where addr in (select paddr from v$session where sid=userenv('sid'));

SPID
------------
24990

Kill掉这个会话的ospid
SQL> create index ind_test on tab01(table_name,column_name,num_nulls) online;
create index ind_test on tab01(table_name,column_name,num_nulls) online
*
ERROR at line 1:
ORA-03113: end-of-file on communication channel

此时无法对这个索引进行删除、重建等
SQL> conn xiaoyu/xiaoyu
Connected.
SQL> drop index ind_test;
drop index ind_test
*
ERROR at line 1:
ORA-08104: this index object 125197 is being online built or rebuilt

数据字典中任然记录这个索引的信息
SQL> select status from user_indexes where index_name='IND_TEST';

STATUS
--------
VALID

SQL> select object_id from user_objects where object_name='IND_TEST';

OBJECT_ID
----------
125197

在oracle 10GR2后我们可以直接用dbms_repair.online_index_clean来进行清除,不再需要使用代价较大的重启数据库、修改字典表ind$等办法
SQL> DECLARE
2 RetVal BOOLEAN;
3 OBJECT_ID BINARY_INTEGER;
4 WAIT_FOR_LOCK BINARY_INTEGER;
5 BEGIN
6 OBJECT_ID := 125197;
7 WAIT_FOR_LOCK := NULL;
8 RetVal := SYS.DBMS_REPAIR.ONLINE_INDEX_CLEAN();
9 COMMIT;
10 END;
11 /
RetVal := SYS.DBMS_REPAIR.ONLINE_INDEX_CLEAN();
*
ERROR at line 8:
ORA-06550: line 8, column 11:
PLS-00201: identifier 'SYS.DBMS_REPAIR' must be declared
ORA-06550: line 8, column 1:
PL/SQL: Statement ignored

这里需要使用sysdba登录
SQL> conn / as sysdba
Connected.
SQL> DECLARE
2 RetVal BOOLEAN;
3 OBJECT_ID BINARY_INTEGER;
4 WAIT_FOR_LOCK BINARY_INTEGER;
5 BEGIN
6 OBJECT_ID := 125197;
7 WAIT_FOR_LOCK := NULL;
8 RetVal := SYS.DBMS_REPAIR.ONLINE_INDEX_CLEAN();
9 COMMIT;
10 END;
11 /

PL/SQL procedure successfully completed.

再次登录发现字典表的索引信息已经清除了,也可以重新对索引进行重建
SQL> conn xiaoyu/xiaoyu
Connected.
SQL> select object_id from user_objects where object_name='IND_TEST';

no rows selected
SQL> select object_id from user_objects where object_name='IND_TEST';

no rows selected
SQL> drop index ind_test;
drop index ind_test
*
ERROR at line 1:
ORA-01418: specified index does not exist

下载本文
显示全文
专题