rebuild online时意外中断 再次重建时报错解决方法

时间:2023-03-09 16:53:46
rebuild online时意外中断 再次重建时报错解决方法

rebuild online时意外中断

再次重建时报错

SQL> alter index PARTY.IDX_CM_INDIV_CUSTOMER_4 rebuild online;

alter index PARTY.IDX_CM_INDIV_CUSTOMER_4 rebuild online

*

ERROR at line 1:

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

DECLARE

isClean BOOLEAN;

BEGIN

isClean := DBMS_REPAIR.ONLINE_INDEX_CLEAN(11652698);

END;

/

下面是MOSC上的解释

SMON will eventually cleanup the locked index so no actions are actually needed. However, letting SMON do the cleanup can be a bit of 'hit and miss' as SMON will try to cleanup every 60 minutes

and if it cannot get a lock on the object with NOWAIT it will just try again later. In a highly active database with many transactions this can cause the rebuild to take a long time as SMON won't get

the lock with NOWAIT. Other cases like uncommitted transactions

against the table will also result in SMON not rebuilding the index.

As long as the index is not rebuild all access to the index will result in ORA-8104 or ORA-8106.           So to solve this situation a manual cleanup can be done using the new function

DBMS_REPAIR.ONLINE_INDEX_CLEAN()

SQL> conn / as sysdba

SQL> DECLARE

isClean BOOLEAN;

BEGIN

isClean := DBMS_REPAIR.ONLINE_INDEX_CLEAN();

END;

/

The function is fully documented in the manual: PL/SQL Packages and Types Reference, 10.2