Oracle/Oh Oracle

ORA-08104, ORA-8106 // CREATE INDEX .. ONLINE 중 오류 발생 시

darkturtle26 2022. 4. 15. 18:15
ORA-08104, ORA-8106 // CREATE INDEX .. ONLINE 중 오류 발생 시
1. CREATE INDEX .. ONLINE  작업 중, 세션이 비정상적으로 종료된 경우, 
   Dictionary 정보는 남게 되어, 재생성 할경우, ORA-08104 에러가 발생함
2. SMON 이 1시간에 한번씩 자동으로 Dictionary Clean 작업 수행함 ( 그냥 놔도두 됨 ) 
3. 버그로 자동 삭제가 안되는 경우, 혹은 빠르게 삭제 하고자 할때
  Manual 하게 아래 패키지 수행 가능 ( sys 유저로 수행 )
  
-- 1. 메타만 남은 INDEX 의 OBJECT_ID 확인 
select object_id from dba_objects where object_name ='온라인인덱스명' and owner ='SCOTT'
-- 2. INDEX 의 OBJECT_ID 를 가기조 삭제 하기
declare
  v_ret boolean;
  begin
  v_ret := dbms_repair.online_index_clean(1171412);  -- SQL1) 에서 확인한 OBJECT_ID 입력
end;
 
<< 참고 문서 >>
How to Cleanup and Rebuild an Interrupted Online Index Rebuild - ORA-8104 , ORA-8106 (문서 ID 272735.1)
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()
conn / as sysdba

DECLARE
isClean BOOLEAN;
BEGIN
isClean := DBMS_REPAIR.ONLINE_INDEX_CLEAN();
END;
/
-- OBJECT_ID 를 주지 않으면, 현재 걸려 있는 INDEX 메타를 퍼지하는 걸로 보임
-- OBJECT_ID 주고 퍼지는 몇차례 경험 ㅇ.ㅇ