SMON功能(三):清理obj$基表
SMON的作用還包括清理obj$資料字典基表(cleanup obj$)
OBJ$字典基表是Oracle Bootstarp啟動自舉的重要物件之一:
SQL> set linesize 80 ;
SQL> select sql_text from bootstrap$ where sql_text like 'CREATE TABLE OBJ$%';
SQL_TEXT
--------------------------------------------------------------------------------
CREATE TABLE OBJ$("OBJ#" NUMBER NOT NULL,"DATAOBJ#" NUMBER,"OWNER#" NUMBER NOT N
ULL,"NAME" VARCHAR2(30) NOT NULL,"NAMESPACE" NUMBER NOT NULL,"SUBNAME" VARCHAR2(
30),"TYPE#" NUMBER NOT NULL,"CTIME" DATE NOT NULL,"MTIME" DATE NOT NULL,"STIME"
DATE NOT NULL,"STATUS" NUMBER NOT NULL,"REMOTEOWNER" VARCHAR2(30),"LINKNAME" VAR
CHAR2(128),"FLAGS" NUMBER,"OID$" RAW(16),"SPARE1" NUMBER,"SPARE2" NUMBER,"SPARE3
" NUMBER,"SPARE4" VARCHAR2(1000),"SPARE5" VARCHAR2(1000),"SPARE6" DATE) PCTFREE
10 PCTUSED 40 INITRANS 1 MAXTRANS 255 STORAGE ( INITIAL 16K NEXT 1024K MINEXTEN
TS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 OBJNO 18 EXTENTS (FILE 1 BLOCK 121))
觸發場景
OBJ$基表是一張低階資料字典表,該表幾乎對庫中的每個物件(表、索引、包、檢視等)都包含有一行記錄。很多情況下,這些條目所代表的物件是不存在的物件(non-existent),引起這種現象的一種可能的原因是物件本身已經被從資料庫中刪除了,但是物件條目仍被保留下來以滿足消極依賴機制(negative dependency)。因為這些條目的存在會導致OBJ$表不斷膨脹,這時就需要由SMON程式來刪除這些不再需要的行。SMON會在例項啟動(after startup of DB is started cleanup function again)時以及啟動後的每12個小時執行一次清理任務(the cleanup is scheduled to run after startup and then every 12 hours)。
我們可以通過以下演示來了解SMON清理obj$的過程:
SQL> BEGIN 2 FOR i IN 1 .. 5000 LOOP 3 execute immediate ('create synonym gustav' || i || ' for 4 perfstat.sometable'); 5 execute immediate ('drop synonym gustav' || i ); 6 END LOOP; 7 END; 8 / PL/SQL procedure successfully completed. SQL> startup force; ORACLE instance started. Total System Global Area 1065353216 bytes Fixed Size 2089336 bytes Variable Size 486542984 bytes Database Buffers 570425344 bytes Redo Buffers 6295552 bytes Database mounted. Database opened. SQL> select count(*) from user$ u, obj$ o 2 where u.user# (+)=o.owner# and o.type#=10 and not exists 3 (select p_obj# from dependency$ where p_obj# = o.obj#); COUNT(*) ---------- 5000 SQL> / COUNT(*) ---------- 5000 SQL> / COUNT(*) ---------- 4951 SQL> oradebug setospid 18457; Oracle pid: 8, Unix process pid: 18457, image: oracle@rh2.oracle.com (SMON) SQL> oradebug event 10046 trace name context forever ,level 1; Statement processed. SQL> oradebug tracefile_name; /s01/admin/G10R2/bdump/g10r2_smon_18457.trc select o.owner#, o.obj#, decode(o.linkname, null, decode(u.name, null, 'SYS', u.name), o.remoteowner), o.name, o.linkname, o.namespace, o.subname from user$ u, obj$ o where u.use r#(+) = o.owner# and o.type# = :1 and not exists (select p_obj# from dependency$ where p_obj# = o.obj#) order by o.obj# for update select null from obj$ where obj# = :1 and type# = :2 and obj# not in (select p_obj# from dependency$ where p_obj# = obj$.obj#) delete from obj$ where obj# = :1 /* 刪除過程其實較為複雜,可能要刪除多個字典基表上的記錄 */
現象
我們可以通過以下查詢來了解obj$基表中NON-EXISTENT物件的條目總數(type#=10),若這個總數在不斷減少說明smon正在執行清理工作
select trunc(mtime), substr(name, 1, 3) name, count(*) from obj$ where type# = 10 and not exists (select * from dependency$ where obj# = p_obj#) group by trunc(mtime), substr(name, 1, 3); select count(*) from user$ u, obj$ o where u.user#(+) = o.owner# and o.type# = 10 and not exists (select p_obj# from dependency$ where p_obj# = o.obj#);
如何禁止SMON清理obj$基表
我們可以通過設定診斷事件event=’10052 trace name context forever’來禁止SMON清理obj$基表,當我們需要避免SMON因cleanup obj$的相關程式碼而意外終止或spin從而開展進一步的診斷時可以設定該診斷事件。在Oracle並行伺服器或RAC環境中,也可以設定該事件來保證只有特定的某個節點來執行清理工作。
10052, 00000, "don't clean up obj$" alter system set events '10052 trace name context forever, level 65535'; Problem Description: We are receiving the below warning during db startup:
WARNING: kqlclo() has detected the following :
Non-existent object 37336 NOT deleted because an object
of the same name exists already.
Object name: PUBLIC.USER$
This is caused by the SMON trying to cleanup the SYS.OJB$.
SMON cleans all dropped objects which have a SYS.OBJ$.TYPE#=10.
This can happen very often when you create an object that have the same name as a public synonym.
When SMON is trying to remove non-existent objects and fails because there are duplicates,
multiple nonexistent objects with same name.
This query will returned many objects with same name under SYS schema:
select o.name,u.user# from user$ u, obj$ o where u.user# (+)=o.owner# and o.type#=10
and not exists (select p_obj# from dependency$ where p_obj# = o.obj#);
To cleanup this message:
Take a full backup of the database - this is crucial. If anything goes wrong during this procedure,
your only option would be to restore from backup, so make sure you have a good backup before proceeding.
We suggest a COLD backup. If you plan to use a HOT backup, you will have to restore point in time if any problem happens
Normally DML against dictionary objects is unsupported,
but in this case we know exactly what the type of corruption,
also you are instructing to do this under guidance from Support.
Data dictionary patching must be done by an experienced DBA.
This solution is unsupported.
It means that if there were problems after applying this solution, a database backup must be restored.
1. Set event 10052 at parameter file to disable cleanup of OBJ$ by SMON
EVENT="10052 trace name context forever, level 65535"
2. Startup database in restricted mode
3. Delete from OBJ$, COMMIT
SQL> delete from obj$ where (name,owner#) in ( select o.name,u.user# from user$ u, obj$ o
where u.user# (+)=o.owner# and o.type#=10 and not exists (select p_obj# from
dependency$ where p_obj# = o.obj#) );
SQL> commit;
SQL> Shutdown abort.
4. remove event 10052 from init.ora
5. Restart the database and monitor for the message in the ALERT LOG file
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/22990797/viewspace-2128772/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 瞭解你所不知道的SMON功能(三):清理obj$基表OBJ
- 【eygle】Oracle程式:SMON的功能與作用Oracle
- Oracle程式:SMON的功能與作用 ZTOracle
- oracle smon與pmon ckpt功能的作用(ZT)Oracle
- 【蓋國強】Oracle程式:SMON的功能與作用Oracle
- oracle底層字典表obj$及source$與儲存過程procedure系列三OracleOBJ儲存過程
- 三維引擎匯入obj模型不可見總結OBJ模型
- 三維引擎匯入obj模型全黑總結OBJ模型
- SMON程式詳解
- SMON 程式的作用
- Oracle清理SYSAUX表空間OracleUX
- iOS快取清理功能的實現iOS快取
- SMON: Parallel transaction recovery triedParallel
- Oracle SMON程式的作用Oracle
- Oracle大表清理truncate .. reuse storageOracle
- 使用java實現希表的基礎功能Java
- 【AWR】清理SYSAUX表空間資料(第三季非暴力不合作)UX
- C_OBJ#_INTCOL#OBJ
- SMON故障造成的parallel rollbackParallel
- Java3D應用例項-載入Obj 三維模型Java3DOBJ模型
- SYSAUX表空間清理之SM/OPTSTATUX
- ORACLE臨時表空間的清理Oracle
- 多功能綜合系統清理優化MacCleaner PRO優化Mac
- Omni Remover for Mac(多功能系統清理軟體)REMMac
- iOS開發-清理快取功能的實現iOS快取
- [物件轉原始型別總結] (‘ + obj) === `${obj}`? 不一定!物件型別OBJ
- Oracle SMON系統監視程式Oracle
- LGWR DBWR SMON 等程式說明
- System Monitor Process (SMON) (120)
- 定位demo(Obj-C)OBJ
- [Javascript] Reflect vs obj[key]JavaScriptOBJ
- 清理臨時表規範以及指令碼指令碼
- 實錄:oracle下大表清理整改薦Oracle
- oracle清理和重建臨時表空間Oracle
- win10 2004檔案清理功能如何使用_win10 2004使用檔案清理功能的步驟Win10
- oracle底層字典表obj$及source$與儲存過程procedure系列一OracleOBJ儲存過程
- oracle底層字典表obj$及source$與儲存過程procedure系列二OracleOBJ儲存過程
- oracle底層字典表obj$及source$與儲存過程procedure系列四OracleOBJ儲存過程