Online rebuild index遭遇ORA-08104

在online rebuild index的過程中,如果中途異常終止(比如按ctrl+c強行退出),運氣不好的話,可能會遇到問題,在你想重新rebuild index(或者drop,analyze)的時候,報錯:

ORA-08104: this index object 67420 is being online built or rebuilt

這是由於在異常終止online rebuild操作的時候,oracle沒來得及清理相應的臨時段和標誌位,系統認爲online rebuild操作還在進行造成的。在Oracle10g之前,對於這種情況沒有太好的辦法,只有等SMON進程來進行清理了。網上有說上重啓可以解決,有說直接update系統表ind$的,對於不能停機的產品庫來說,這些都是不可取的方案。重啓不現實,修改系統表更是DBA的大忌。Oracle10g則可以使用dbms_repair.online_index_clean手工清理(metalink的說法,9i打了Bug 3805539的patch的話也能用該過程了)。所以,對於大索引的online rebuild,不要輕易中止。否則可能要等上相當一段時間SMON才能完成清理工作,清理完後,可以在alert.log中看到如下記錄:

User:,time:20071209 03:12:09,program:oracle@db1 (SMON),IP:,object:SYS_JOURNAL_67420,DDL: drop table "TAOBAO"."SYS_JOURNAL_67420"

 

異常終止的情況下,可以發現ind$關於該索引的狀態還是online rebuild的:

SQL> select obj#,flags from ind$ where obj#=67420;

      OBJ#      FLAGS
---------- ----------
     67420        514

Flag字段的說明可以在ind$的sql.bsq腳本中找到:

/* mutable flags: anything permanent should go into property */
/* unusable (dls) : 0x01 */
/* analyzed       : 0x02 */
/* no logging     : 0x04 */
/* index is currently being built : 0x08 */
/* index creation was incomplete : 0x10 */
/* key compression enabled : 0x20 */
/* user-specified stats : 0x40 */
/* secondary index on IOT : 0x80 */
/* index is being online built : 0x100 */
/* index is being online rebuilt : 0x200 */
/* index is disabled : 0x400 */
/* global stats : 0x800 */
/* fake index(internal) : 0x1000 */
/* index on UROWID column(s) : 0x2000 */
/* index with large key : 0x4000 */
/* move partitioned rows in base table : 0x8000 */
/* index usage monitoring enabled : 0x10000 */

514=0×202,表示該索引狀態爲index is being online rebuilt : 0×200 + analyzed : 0×02

在SMON完成清理動作後,再次查詢索引狀態已經恢復正常:

SQL> select obj#,flags from ind$ where obj#=67420;

      OBJ#      FLAGS
---------- ----------
     67420          2

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章