執(zhí)行DML 期間,為防止對與DML 相關(guān)的對象進(jìn)行修改,執(zhí)行DML 的進(jìn)程必須對該表獲得TM 鎖。
為都安等地區(qū)用戶提供了全套網(wǎng)頁設(shè)計(jì)制作服務(wù),及都安網(wǎng)站建設(shè)行業(yè)解決方案。主營業(yè)務(wù)為成都網(wǎng)站設(shè)計(jì)、網(wǎng)站制作、外貿(mào)營銷網(wǎng)站建設(shè)、都安網(wǎng)站設(shè)計(jì),以傳統(tǒng)方式定制建設(shè)網(wǎng)站,并提供域名空間備案等一條龍服務(wù),秉承以專業(yè)、用心的態(tài)度為用戶提供真誠的服務(wù)。我們深信只要達(dá)到每一位用戶的要求,就會(huì)得到認(rèn)可,從而選擇與我們長期合作。這樣,我們也可以走得更遠(yuǎn)!
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 ; |
一般發(fā)生TM 爭用的情況如下:
l DDL 動(dòng)作
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 外鍵約束無索引
會(huì)話1 :
SYS@cdbtest1(CDB$ROOT)> lock table t in exclusive mode; Table(s) Locked. |
會(huì)話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.