<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>惜分飞 &#187; enq: TX &#8211; contention</title>
	<atom:link href="https://www.xifenfei.com/tag/enq-tx-contention/feed" rel="self" type="application/rss+xml" />
	<link>https://www.xifenfei.com</link>
	<description>提供7*24专业数据库(Oracle,SQL Server,MySQL,PostgreSQL等)恢复和技术支持@Tel:17813235971</description>
	<lastBuildDate>Sat, 07 Nov 2026 15:45:44 +0000</lastBuildDate>
	<language>zh-CN</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	
	<item>
		<title>rac kill 大事物后回滚慢,smon等待DFS lock handle和enq: TX &#8211; contention</title>
		<link>https://www.xifenfei.com/2022/11/smon-wait-dfs-lock-handle-enq-tx-contention.html</link>
		<comments>https://www.xifenfei.com/2022/11/smon-wait-dfs-lock-handle-enq-tx-contention.html#comments</comments>
		<pubDate>Tue, 08 Nov 2022 09:34:31 +0000</pubDate>
		<dc:creator><![CDATA[惜分飞]]></dc:creator>
				<category><![CDATA[Oracle]]></category>
		<category><![CDATA[DFS lock handle]]></category>
		<category><![CDATA[enq: TX - contention]]></category>
		<category><![CDATA[大事物回滚慢]]></category>

		<guid isPermaLink="false">https://www.xifenfei.com/?p=10027</guid>
		<description><![CDATA[联系：手机/微信(+86 17813235971) QQ(107644445)  &#8230; <a href="https://www.xifenfei.com/2022/11/smon-wait-dfs-lock-handle-enq-tx-contention.html">继续阅读 <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<div id="xifenfeicopyright">
<p>联系：<a href="https://www.xifenfei.com/about_xifenfei" target="_blank">手机/微信(+86 17813235971)   QQ(107644445)</a><a target="_blank" href="http://wpa.qq.com/msgrd?v=3&#038;uin=107644445&#038;site=qq&#038;menu=yes"><img src="https://www.xifenfei.com/wp-content/themes/img/site_qq.jpg" alt="QQ咨询惜分飞" title="QQ咨询惜分飞"/></a></p>
<p>标题：<a href="https://www.xifenfei.com/2022/11/smon-wait-dfs-lock-handle-enq-tx-contention.html" target="_blank">rac kill 大事物后回滚慢,smon等待DFS lock handle和enq: TX &#8211; contention</a></p>
<p>作者：<a href="https://www.xifenfei.com" target="_blank">惜分飞</a>©版权所有[未经本人同意,不得以任何形式转载,否则有进一步追究法律责任的权利.]</p>
</div>
<p>Customer killed a large DELETE statement of a large table in instance 1 in high workload period in RAC environment of 2 instances.<br />
Transaction recovery did not yet complete for more than 1 hour by querying V$FAST_START_TRANSACTIONS.<br />
Update on the same table on instance 2 hung more than 1 hour.<br />
Transaction recovery complete quickly after shutdown instance 2.<br />
ASH shows high waiting on &#8220;enq: TX &#8211; row lock contention&#8221; and &#8220;transaction&#8221; without blocking session until instance 2 shutdown after DELETE session killed in instance 1</p>
<pre class="brush: sql; title: ; notranslate">
SQL&gt; select instance_number,program,event,BLOCKING_INST_ID b_inst,count(session_id) session_cnt,
count(BLOCKING_SESSION) b_session_cnt,min(sample_time) start_time,max(sample_time) end_time,count(*) cnt
  2  from DBA_HIST_ACTIVE_SESS_HISTORY where sql_id='d1xg4v7rqx3kt' and instance_number=2
group by instance_number,program,event,BLOCKING_INST_ID
order by instance_number,start_time
  3    4    5  ;

INSTANCE_NUMBER PROGRAM            EVENT                         B_INST SESSION_CNT B_SESSION_CNT START_TIME END_TIME       CNT
--------------- ------------------ ----------------------------- ------ ----------- ------------- ---------- ---------- -------
              2 JDBC Thin Client   enq: TX - row lock contention             728939             0 19:20:34   21:04:25    728939
              2 JDBC Thin Client   transaction                               489837             0 20:12:44   21:04:25    489837
</pre>
<p>ASH shows that all sessions of the &#8220;enq: TX &#8211; row lock contention&#8221; without blocking session on instance 2 were waiting for the transaction of the Killed DELETE on instance 1</p>
<pre class="brush: sql; title: ; notranslate">
SQL&gt; select instance_number,event,trunc(p2/65536) XIDUSN, trunc(mod(p2,65536)) XIDSLOT, 
p3 XIDSQN,count(session_id) session_cnt,count(BLOCKING_SESSION) b_session_cnt,min(sample_time) start_time,max(sample_time) end_time,count(*) cnt
from DBA_HIST_ACTIVE_SESS_HISTORY where sql_id='d1xg4v7rqx3kt' and instance_number=2 and 
to_char(sample_time,'HH24:MI') &gt;= '20:12' AND BLOCKING_SESSION IS NULL AND EVENT='enq: TX - row lock contention'
group by instance_number,event,trunc(p2/65536) , trunc(mod(p2,65536)) , p3
order by start_time
;
  2    3    4    5

INSTANCE_NUMBER EVENT                            XIDUSN  XIDSLOT   XIDSQN SESSION_CNT B_SESSION_CNT START_TIME END_TIME      CNT
--------------- ------------------------------ -------- -------- -------- ----------- ------------- ---------- ---------- ------
              2 enq: TX - row lock contention       932       15   623055      717850             0 20:12:55   21:04:25   717850
SQL&gt;
</pre>
<p>ASH shows that SMON of instance 1 was waiting for &#8220;DFS lock handle&#8221; and &#8220;enq: TX &#8211; contention&#8221; among  DELETE session killed in instance 1 and instance 2 shutdown.</p>
<pre class="brush: sql; title: ; notranslate">
SQL&gt; select instance_number,session_id,session_serial#,program,event,BLOCKING_SESSION b_sid,
BLOCKING_SESSION_SERIAL# b_serial,BLOCKING_INST_ID b_inst,min(sample_time) start_time,
max(sample_time) end_time,count(*) cnt
 from DBA_HIST_ACTIVE_SESS_HISTORY where upper(program) like '%SMON%'
group by instance_number,session_id,session_serial#,program,event,BLOCKING_SESSION ,BLOCKING_SESSION_SERIAL# ,BLOCKING_INST_ID
order by instance_number,start_time
;

INSTANCE_NUMBER SESSION_ID SESSION_SERIAL# PROGRAM                       EVENT                 B_SID  B_SERIAL B_INST START_TIME END_TIME   CNT
--------------- ---------- --------------- ----------------------------- --------------------- ----- --------- ------ ---------- ---------- ---
              1       3761               1 oracle@&lt;instance_name&gt; (SMON) DFS lock handle                              19:05:24   21:05:07   128
              1       3761               1 oracle@&lt;instance_name&gt; (SMON) enq: TX - contention                         20:14:31   21:04:47    50
</pre>
<p>The P1 of &#8220;DFS lock handle&#8221; shows that SMON was requesting TA enqueue through cross instance calls which is used for serializing operations on undo segments and undo tablespaces</p>
<pre class="brush: sql; title: ; notranslate">
SQL&gt; col event for a20
select instance_number,sample_time,session_id,session_serial#,program,event,p1,p2,p3
  from DBA_HIST_ACTIVE_SESS_HISTORY where upper(program) like '%SMON%' AND EVENT='DFS lock handle' ;
  SQL&gt;   2
INSTANCE_NUMBER SAMPLE_TIME     SESSION_ID SESSION_SERIAL# PROGRAM                       EVENT                      P1     P2     P3
--------------- --------------- ---------- --------------- ----------------------------- ---------------- ------------ ------ ------
              1 19:05:24              3761               1 oracle@&lt;instance_name&gt; (SMON) DFS lock handle    1413545989      3   4722
              1 20:12:27              3761               1 oracle@&lt;instance_name&gt; (SMON) DFS lock handle    1413545989      3   6668
              1 20:13:40              3761               1 oracle@&lt;instance_name&gt; (SMON) DFS lock handle    1413545989      3   5787
              1 20:13:50              3761               1 oracle@&lt;instance_name&gt; (SMON) DFS lock handle    1413545989      3   5580
              1 20:14:00              3761               1 oracle@&lt;instance_name&gt; (SMON) DFS lock handle    1413545989      3   5826
... ...
              1 21:04:57              3761               1 oracle@&lt;instance_name&gt; (SMON) DFS lock handle    1413545989      3   1347
              1 21:05:07              3761               1 oracle@&lt;instance_name&gt; (SMON) DFS lock handle    1413545989      3   4582

144 rows selected.

* All of P1 is 1413545989, converted to hexadecimal: ‭54410005‬, 54 ASCII code: T, 41 ASCII code: A =&gt; TA enqueue
</pre>
<p>The P2,P3 of &#8220;enq: TX &#8211; row lock contention&#8221; shows that SMON process was requesting TX enqueue of the UNDO block of the transaction of the Killed DELETE on instance 1.</p>
<pre class="brush: sql; title: ; notranslate">
SQL&gt; select instance_number,session_id,session_serial#,program,event,trunc(p2/65536) XIDUSN, trunc(mod(p2,65536)) XIDSLOT, p3 XIDSQN,COUNT(1) CNT,min(sample_time) start_time,max(sample_time) end_time
from DBA_HIST_ACTIVE_SESS_HISTORY WHERE session_id =3761 and SESSION_SERIAL# = 1 and instance_number=1 AND event like 'enq: TX - contention%'
group by instance_number,session_id,session_serial#,program,event,trunc(p2/65536) , trunc(mod(p2,65536)) , p3
;
  2    3    4
INSTANCE_NUMBER SESSION_ID SESSION_SERIAL# PROGRAM                        EVENT                  XIDUSN  XIDSLOT   XIDSQN CNT START_TIME END_TIME
--------------- ---------- --------------- ------------------------------ -------------------- -------- -------- -------- --- ---------- ----------
              1       3761               1 oracle@&lt;instance_name&gt; (SMON)  enq: TX - contention      932       15   623055  50 20:14:31   21:04:47

SQL&gt;
SQL&gt; select instance_number,session_id,session_serial#,program,event,CURRENT_OBJ#, CURRENT_FILE#, CURRENT_BLOCK#,CURRENT_ROW#,COUNT(1) CNT,min(sample_time) start_time,max(sample_time) end_time
  2  from DBA_HIST_ACTIVE_SESS_HISTORY WHERE session_id =3761 and SESSION_SERIAL# = 1 and instance_number=1 AND event like 'enq: TX - contention%'
group by instance_number,session_id,session_serial#,program,event,CURRENT_OBJ#, CURRENT_FILE#, CURRENT_BLOCK#,CURRENT_ROW#
order by start_time
;
  3    4    5
INSTANCE_NUMBER SESSION_ID SESSION_SERIAL# PROGRAM                       EVENT                CURRENT_OBJ# CURRENT_FILE# CURRENT_BLOCK# CURRENT_ROW#   CNT START_TIME END_TIME
--------------- ---------- --------------- ----------------------------- -------------------- ------------ ------------- -------------- ------------ ----- ---------- ----------
              1       3761               1 oracle@&lt;instance_name&gt; (SMON) enq: TX - contention            1            42              4            0     1 20:14:31   20:14:31
              1       3761               1 oracle@&lt;instance_name&gt; (SMON) enq: TX - contention            1             3              3            0     1 20:16:22   20:16:22 &lt;&lt;&lt;&lt;CURRENT_FILE#:3 ==&gt;UNDO
              1       3761               1 oracle@&lt;instance_name&gt; (SMON) enq: TX - contention            1             3              5            0     4 20:22:17   20:25:49 &lt;&lt;&lt;&lt;CURRENT_FILE#:3 ==&gt;UNDO
              1       3761               1 oracle@&lt;instance_name&gt; (SMON) enq: TX - contention            0             3           1920            0   3 20:30:13   20:30:33 &lt;&lt;&lt;&lt;CURRENT_FILE#:3 ==&gt;UNDO
              1       3761               1 oracle@&lt;instance_name&gt; (SMON) enq: TX - contention            0             3          15728            0 23 20:37:58   20:52:39 &lt;&lt;&lt;&lt;CURRENT_FILE#:3 ==&gt;UNDO
              1       3761               1 oracle@&lt;instance_name&gt; (SMON) enq: TX - contention            1          1002              2            0    18 20:53:09   21:04:47

6 rows selected.

SQL&gt;
</pre>
<p>解决方案<br />
Please avoid to kill large transaction during high workload period.<br />
If has to kill large transaction, shutdown all remote instances can speed up the transaction recovery.<br />
参考:Transaction Recovery Slow And High Row Lock Contention After Killed Large Transaction in RAC (Doc ID 2668617.1)</p>
<div id="crp_related"><ul><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2023/04/vwait_chains.html" rel="bookmark" class="crp_title">V$Wait_Chains定位阻塞源头</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2011/08/vlock%e8%a7%86%e5%9b%be.html" rel="bookmark" class="crp_title">V$LOCK视图相关知识</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2012/05/hanganalyze%e5%88%86%e6%9e%90%e4%bc%9a%e8%af%9d%e9%98%bb%e5%a1%9e-%e9%94%81%e8%a1%a8.html" rel="bookmark" class="crp_title">Hanganalyze分析会话阻塞&#8212;锁表</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2012/02/%e9%80%9a%e8%bf%87sql%e8%af%ad%e5%8f%a5%e8%8e%b7%e5%8f%96awrstatspack%e9%80%bb%e8%be%91%e8%af%bb%e7%89%a9%e7%90%86%e8%af%bb.html" rel="bookmark" class="crp_title">通过sql语句获取awr/statspack逻辑读/物理读</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2012/06/to-find-the-tx-enqueue-contention-in-a-rac-or-ops-environment.html" rel="bookmark" class="crp_title">To find the TX Enqueue contention in a RAC or OPS environment</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2012/05/library-cache-pin%e7%ad%89%e5%be%85%e4%ba%8b%e4%bb%b6.html" rel="bookmark" class="crp_title">library cache pin等待事件</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2012/05/cursor-pin-s-wait-on-x-%e7%ad%89%e5%be%85%e4%ba%8b%e4%bb%b6.html" rel="bookmark" class="crp_title">cursor: pin S wait on X 等待事件</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2022/10/oracle-open-hang.html" rel="bookmark" class="crp_title">oracle open hang 等待cursor: pin S wait on X</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2020/12/dblink-library-cache-lock.html" rel="bookmark" class="crp_title">dblink会话引起library cache lock</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2012/07/%e5%88%86%e6%9e%90%e4%b8%80%e4%be%8b-tx-enqueue-contention%e6%a1%88%e4%be%8b.html" rel="bookmark" class="crp_title">分析一例 TX Enqueue contention案例</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2012/05/systemstates%e5%88%86%e6%9e%90%e4%bc%9a%e8%af%9d%e9%98%bb%e5%a1%9e-%e9%94%81.html" rel="bookmark" class="crp_title">Systemstates分析会话阻塞&#8212;锁表</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2012/05/library-cache-lock%e7%ad%89%e5%be%85%e4%ba%8b%e4%bb%b6.html" rel="bookmark" class="crp_title">library cache lock等待事件</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>https://www.xifenfei.com/2022/11/smon-wait-dfs-lock-handle-enq-tx-contention.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
