Oracle Enqueues Wait Events 二
enq: TM – contention 原理即解決方法
enq: TM – contention 等待事件通常是由於正在DML操作的的表上的外來鍵約束失效導致。一旦我們找到問題的根源,我們就可以為那些使用外來鍵的表新增外來鍵約束來解決該問題。
(原文:The enq: TM – contention event is usually due to missing foreign key constraints on a table that’s part of an Oracle DML operation. Once you fix the problem by adding the foreign key constraint to the relevant table, the enq: TM – contention event will go away.)
enq: TM – contention等待事件會話有可能是由於正在執行的insert 語句的表的外來鍵沒有相關約束,即當引用父表的依賴表或子表的外來鍵約束缺少關聯鍵上的索引時,會發生這種情況,同時還會當Oracle對父表中由子表的外來鍵引用的主鍵列執行修改,它還將獲得子表的表級鎖。
(The waits on the enq: TM – contention event for the sessions that are waiting to perform insert operations are almost always due to an unindexed foreign key constraint.. This happens when a dependent or child table’s foreign key constraint that references a parent table is missing an index on the associated key. Oracle acquires a table lock on a child table if it’s performing modifications on the primary key column in the parent table that’s referenced by the foreign key of the child table. )
它對父表中由子表的外來鍵引用的主鍵列執行修改。注意,這些是全表鎖(TM),而不是行級鎖(TX)——因此,這些鎖不是某一行,而是對於整個表。自然,一旦獲得了這個表鎖,Oracle將阻止所有其他試圖修改子表資料的會話。一旦在引用父表的列作為子表的外來鍵列上建立索引,那麼TM爭用而引起的等待就會消失。
(原文:it’s performing modifications on the primary key column in the parent table that’s referenced by the foreign key of the child table.Note that these are full table locks (TM), and not row-level locks (TX)—thus, these locks aren’t restricted to a row but to the entire table. Naturally, once this table lock is acquired, Oracle will block all other sessions that seek to modify the child table’s data. Once you create an index in the child table performing on the column that references the parent table, the waits due to the TM contention will go away.)
如果在新增索引的時候報ORA-00054,那麼就需要我們確認當前那個會話阻塞了,和業務確認後把會話kill,再執行:
新增索引有可能的報錯:ORA-00054: resource busy and acquire with NOWAIT specified
確認當前阻塞會話資訊:(11G-19C)
select s.inst_id inst, s.sid, s.serial#, s.username, substr(s.program,1,15) program, s.sql_id, s.event,machine,OSUSER,round(last_call_et/60,2) lmins ,s.seq#,module
from gv$session s
where s.type <> 'BACKGROUND'
and (s.event not like 'SQL*Net mes%' OR S.event LIKE '%dblink%' ) and s.event != 'reliable message'
and s.wait_class <> 'Idle'
order by inst_id, s.sql_id, s.inst_id, s.program;
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26342786/viewspace-2708979/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Oracle Enqueues Wait Events 一OracleENQAI
- Oracle Enqueues Wait Events 三OracleENQAI
- Oracle Enqueues Wait Events 三 enq: TX - row lock contentionOracleENQAI
- Oracle RAC Wait EventsOracleAI
- Oracle RAC Cache Fusion系列十八:Oracle RAC Statisticsand Wait EventsOracleAI
- ORACLE EVENTS(轉)Oracle
- Oracle RAC Cache Fusion 系列十:Oracle RAC Enqueues And Lock Part 1OracleENQ
- oracle等待事件之cursor:pin S wait on XOracle事件AI
- 【go語言】wait,wait for meGoAI
- Oracle10g等待事件型別wait_class說明Oracle事件型別AI
- [20200120]oracle wait event "enq: SQ – contention" and DBA_DB_LINK_SOURCES.txtOracleAIENQ
- Oracle不同版本檢視資料庫session/system級別設定了哪些eventsOracle資料庫Session
- oracle壞塊(二)Oracle
- oracle重建索引(二)Oracle索引
- efcore 新特性 SaveChanges Events
- pointer-events屬性
- wait() vs sleep()AI
- oracle壓縮表(二)Oracle
- Oracle GoldenGate安裝(二)OracleGo
- CSS3 pointer-eventsCSSS3
- binlog_rows_query_log_events
- Random Events CodeForces - 1461Crandom
- Golang CLOSE WAIT 分析GolangAI
- ORACLE備份策略二(轉)Oracle
- Nodejs學習筆記-01 eventsNodeJS筆記
- Server-sent Events 介面壓測Server
- 簡述 Laravel Model Events 的使用Laravel
- 徹底搞懂 Kubernetes 中的 Events
- 【TUNE_ORACLE】Oracle Hint之常用Hint功能概述(二)Oracle
- 【YashanDB知識庫】YAS-02024 lock wait timeout, wait time 0 millisecondsAI
- 調整time_waitAI
- 10.25 V$SESSION_WAITSessionAI
- cursor pin S wait on XAI
- [20191223]Wait for Java.txtAIJava
- cursor: pin S wait on XAI
- MXNet: wait_to_read 方法AI
- sleep()和wait()區別AI
- TCP連線的TIME_WAIT和CLOSE_WAIT 狀態解說TCPAI