Oracle等待事件之enq: TM – contention
執行DML 期間,為防止對與DML 相關的物件進行修改,執行DML 的程式必須對該表獲得TM 鎖。
P1 = name|mode
P2 = object #
P3 = table/partition
SQL> select name,parameter1,parameter2,parameter3 from v$event_name where name like 'enq: TM - contention';
NAME PARAMETER1 PARAMETER2 PARAMETER3 ------------------------------ -------------------- -------------------- -------------------- enq: TM - contention name|mode object # table/partition
|
解決辦法:可以通過下面的sql 查詢blocker
SELECT distinct w.tm, w.p2 OBJECT_ID, l.inst_id, l.sid, l.lmode, l.request,l.block FROM ( SELECT p2, p3, 'TM-'||substr(p2raw,-8)||'-'||lpad(p3,8,'0') TM FROM v$session_wait WHERE event='enq: TM - contention' and state='WAITING' ) W, gv$lock L WHERE l.type(+)='TM' and l.id1(+)=w.p2 and l.id2(+)=w.p3 ORDER BY tm, lmode desc, request desc ; |
一般發生TM 爭用的情況如下:
l DDL 動作
l Lock table tab_name in share mode;lock table tab_name in exclusive mode ;
l INSERT /*+ APPEND */ INTO
l SQL*Loader 的direct path load
l 外來鍵約束無索引
模擬enq: TM – contention
會話1 :
SYS@cdbtest1(CDB$ROOT)> lock table t in exclusive mode;
Table(s) Locked. |
會話2 :
SYS@cdbtest1(CDB$ROOT)> update t set object_id=100 where object_id=100; |
查詢等待事件
SYS@cdbtest1(CDB$ROOT)> select inst_id, event#, event,count(*) from gv$session 2 where wait_class# <> 6 3 group by inst_id, event#,event 4 order by 1,4 desc;
INST_ID EVENT# EVENT COUNT(*) ---------- ---------- ------------------------------ ---------- 1 278 enq: TM - contention 1 1 414 SQL*Net message to client 1 |
查詢blocker
SELECT distinct w.tm, w.p2 OBJECT_ID, l.inst_id, l.sid, l.lmode, l.request,l.blocklmode, l.request,l.block FROM 2 3 ( SELECT p2, p3, 'TM-'||substr(p2raw,-8)||'-'||lpad(p3,8,'0') TM 4 FROM v$session_wait 5 WHERE event='enq: TM - contention' 6 and state='WAITING' 7 ) W, 8 gv$lock L 9 WHERE l.type(+)='TM' 10 and l.id1(+)=w.p2 11 and l.id2(+)=w.p3 12 ORDER BY tm, lmode desc, request desc 13 ;
TM OBJECT_ID INST_ID SID LMODE REQUEST BLOCK -------------------- ---------- ---------- ---------- ---------- ---------- ---------- TM-00013866-00000000 79974 1 113 6 0 1 TM-00013866-00000000 79974 1 91 0 3 0 |
阻塞者是113 ,被阻塞者是91.
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/31480688/viewspace-2657904/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- oracle 11.2.0.4 rac叢集等待事件enq: TM - contentionOracle事件ENQ
- oracle等待事件之enq: CF – contentionOracle事件ENQ
- 等待事件enq: TX - row lock contention事件ENQ
- [20220518]enq FU - contention等待事件.txtENQ事件
- 故障排除 | enq:TX - index contention等待事件ENQIndex事件
- 故障處理】佇列等待之enq: US - contention案例佇列ENQ
- 【故障處理】佇列等待之enq: US - contention案例佇列ENQ
- 【TUNE_ORACLE】等待事件之等待事件類別Oracle事件
- Oracle Enqueues Wait Events 三 enq: TX - row lock contentionOracleENQAI
- enq: TM - contention解決之道——外來鍵無索引導致鎖爭用ENQ索引
- enq: TX - allocate ITL entry等待事件分析ENQ事件
- enq: TX - row lock contentionENQ
- ORACLE 如何診斷高水位爭用(enq: HW – contention)OracleENQ
- 關於enq: TX - allocate ITL entry等待事件ENQ事件
- 【TUNE_ORACLE】等待事件之IO等待“read by other session”Oracle事件Session
- 【TUNE_ORACLE】等待事件之IO等待“direct path read”Oracle事件
- 【TUNE_ORACLE】等待事件之IO等待“direct path write”Oracle事件
- [20200120]oracle wait event "enq: SQ – contention" and DBA_DB_LINK_SOURCES.txtOracleAIENQ
- 【TUNE_ORACLE】等待事件之IO等待“db file scattered read”Oracle事件
- 【TUNE_ORACLE】等待事件之IO等待“direct path write temp”Oracle事件
- 【TUNE_ORACLE】等待事件之IO等待“db file sequential read”Oracle事件
- 【TUNE_ORACLE】等待事件之IO等待“db file parallel write”Oracle事件Parallel
- oracle等待事件之cursor:pin S wait on XOracle事件AI
- 【TUNE_ORACLE】等待事件之“library cache lock”Oracle事件
- 【TUNE_ORACLE】等待事件之“buffer busy waits”Oracle事件AI
- 【TUNE_ORACLE】等待事件之“library cache pins”Oracle事件
- 奇異的enq: TX - row lock contentionENQ
- enq: TX - index contention基礎理論ENQIndex
- ORACLE 常見等待事件Oracle事件
- 效能問題,AWR High Event enq: US - contentionENQ
- Oracle優化案例-系統切換引起的enq: SQ - contention(二十八)Oracle優化ENQ
- Oracle常見UNDO等待事件Oracle事件
- enq: TX - index contention故障修復一例ENQIndex
- RAC中的enq: TS等待ENQ
- 【TUNE_ORACLE】等待事件之日誌等待“log file sync”Oracle事件
- 【TUNE_ORACLE】等待事件之日誌等待“log file parallel write”Oracle事件Parallel
- Oracle面試寶典-等待事件篇Oracle面試事件
- Systematic Latch Contention Troubleshooting in OracleOracle