測試index online rebuild故障記錄
測試資料
SQL> select count(*) from t;COUNT(*)
----------
596528
SQL> create index online_test on t(object_id);
Index created.
SQL> select object_id from dba_objects where object_name = 'ONLINE_TEST';
OBJECT_ID
----------
75783
OBJECT_ID
----------
75783
SQL> select FLAGS from ind$ where obj# = 75783;
FLAGS
----------
2
FLAGS
----------
2
SQL> select status from dba_indexes where index_name = 'ONLINE_TEST';
STATUS
--------
VALID
STATUS
--------
VALID
線上重建索引,途中殺掉程式
SQL> alter index online_test rebuild online;
alter index online_test rebuild online
*
ERROR at line 1:
ORA-03113: end-of-file on communication channel
Process ID: 2565
Session ID: 39 Serial number: 1
alter index online_test rebuild online
*
ERROR at line 1:
ORA-03113: end-of-file on communication channel
Process ID: 2565
Session ID: 39 Serial number: 1
此時的狀態
SQL> select FLAGS from ind$ where obj# = 75783;
FLAGS
----------
514
FLAGS
----------
514
SQL> select status from dba_indexes where index_name = 'ONLINE_TEST';
STATUS
--------
VALID
STATUS
--------
VALID
資料庫內殘留了一張表,用於線上重建索引時,記錄基表改變
SQL> select table_name from dba_tables where table_name like '%75783%';
TABLE_NAME
------------------------------
SYS_JOURNAL_75783
TABLE_NAME
------------------------------
SYS_JOURNAL_75783
SQL> desc SYS_JOURNAL_75783;
Name Null? Type
----------------------------------------- -------- ----------------------------
C0 NOT NULL NUMBER
OPCODE CHAR(1)
PARTNO NUMBER
RID NOT NULL ROWID
Name Null? Type
----------------------------------------- -------- ----------------------------
C0 NOT NULL NUMBER
OPCODE CHAR(1)
PARTNO NUMBER
RID NOT NULL ROWID
索引仍然是可用狀態
Execution Plan
----------------------------------------------------------
Plan hash value: 688999315
---------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
---------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 13 | 3 (0)| 00:00:01 |
| 1 | SORT AGGREGATE | | 1 | 13 | | |
|* 2 | INDEX RANGE SCAN| ONLINE_TEST | 8 | 104 | 3 (0)| 00:00:01 |
---------------------------------------------------------------------------------
----------------------------------------------------------
Plan hash value: 688999315
---------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
---------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 13 | 3 (0)| 00:00:01 |
| 1 | SORT AGGREGATE | | 1 | 13 | | |
|* 2 | INDEX RANGE SCAN| ONLINE_TEST | 8 | 104 | 3 (0)| 00:00:01 |
---------------------------------------------------------------------------------
但是無法對索引進行操作了
SQL> alter index online_test rebuild online;
alter index online_test rebuild online
*
ERROR at line 1:
ORA-08104: this index object 75783 is being online built or rebuilt
SQL> alter index online_test rebuild;
alter index online_test rebuild
*
ERROR at line 1:
ORA-08104: this index object 75783 is being online built or rebuilt
alter index online_test rebuild online
*
ERROR at line 1:
ORA-08104: this index object 75783 is being online built or rebuilt
SQL> alter index online_test rebuild;
alter index online_test rebuild
*
ERROR at line 1:
ORA-08104: this index object 75783 is being online built or rebuilt
SQL> drop index online_test;
drop index online_test
*
ERROR at line 1:
ORA-08104: this index object 75783 is being online built or rebuilt
drop index online_test
*
ERROR at line 1:
ORA-08104: this index object 75783 is being online built or rebuilt
解決方法:呼叫函式(10g及以上)
declare
ok boolean;
begin
ok := false;
while ok=false loop
ok := dbms_repair.online_index_clean(75783); --75783是索引的object_id
dbms_lock.sleep(2);
end loop;
end;
begin
ok := false;
while ok=false loop
ok := dbms_repair.online_index_clean(75783); --75783是索引的object_id
dbms_lock.sleep(2);
end loop;
end;
/
dbms_repair.online_index_clean如果不加任何引數,就是清理所有online rebuild中斷的索引
PL/SQL procedure successfully completed.
SQL> select FLAGS from ind$ where obj# = 75783;
FLAGS
----------
2
FLAGS
----------
2
SQL> select table_name from dba_tables where table_name like '%75783%';
no rows selected
no rows selected
SQL> alter index online_test rebuild online;
Index altered.
Index altered.
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26239116/viewspace-1130714/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Index Online RebuildIndexRebuild
- alter index rebuild 與 rebuild onlineIndexRebuild
- create index online 與rebuild index onlineIndexRebuild
- create index online 與rebuild index onlineIndexRebuild
- 聊聊索引Index Rebuild和Rebuild Online(下)索引IndexRebuild
- 聊聊索引Index Rebuild和Rebuild Online(上)索引IndexRebuild
- alter index rebuild和rebuild online的區別IndexRebuild
- 【羅玄】從鎖的角度看rebuild index online和rebuild indexRebuildIndex
- index rebuild online的問題IndexRebuild
- alter index ind1 rebuild 和alter index ind1 rebuild onlineIndexRebuild
- create index , rebuild index troubleshooting 索引故障解決IndexRebuild索引
- rebuild index online和create index online及沒有online的區別RebuildIndex
- alter index rebuild online引發的血案IndexRebuild
- alter index ... rebuild online的機制(zt)IndexRebuild
- “rebuild index online hang住" 問題解析RebuildIndex
- 關於rebuild index online 及drop index後重建問題RebuildIndex
- rebuild index online的鎖機制淺析RebuildIndex
- Online rebuild index遭遇ORA-08104RebuildIndex
- 重建索引index rebuild online vs offline vs index coalesce vs index shrik space索引IndexRebuild
- 關於move table和rebuild index批量操作的記錄RebuildIndex
- rebuild indexRebuildIndex
- index rebuildIndexRebuild
- oracle10g_alter index rebuild_online_重構索引OracleIndexRebuild索引
- (轉)Index Rebuild Online 過程(9i)完整版IndexRebuild
- rebuild index 排序RebuildIndex排序
- sybase rebuild indexRebuildIndex
- rebuild與rebuild online效率比對Rebuild
- "Alter index rebuild online parallel n"會修改索引的degree屬性IndexRebuildParallel索引
- best practice of rebuild your partition table local index online by using: "update indexes"RebuildIndex
- Index rebuild --case 1IndexRebuild
- 索引rebuild和rebuild online時要慎重索引Rebuild
- alter index rebuild與index_statsIndexRebuild
- ORACLE中index的rebuildOracleIndexRebuild
- 索引rebuild和rebuild online時要慎重(轉載)索引Rebuild
- Oracle alter index rebuild 說明OracleIndexRebuild
- rebuild index 和 recreate index (重新建立index) 的區別RebuildIndex
- 單元測試 - 測試場景記錄
- create index .. onlineIndex