<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: Deadlock</title>
	<atom:link href="http://jonathanlewis.wordpress.com/2011/04/08/deadlock/feed/" rel="self" type="application/rss+xml" />
	<link>http://jonathanlewis.wordpress.com/2011/04/08/deadlock/</link>
	<description>Just another Oracle weblog</description>
	<lastBuildDate>Wed, 22 May 2013 01:50:53 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: Martin Decker</title>
		<link>http://jonathanlewis.wordpress.com/2011/04/08/deadlock/#comment-40502</link>
		<dc:creator><![CDATA[Martin Decker]]></dc:creator>
		<pubDate>Wed, 11 May 2011 09:14:57 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=6169#comment-40502</guid>
		<description><![CDATA[Hi Jonathan,

the same deadlock tree appears if the reason is ITL contention on heap table:
[sourcecode]
Deadlock graph:
                       ---------Blocker(s)--------  ---------Waiter(s)---------
Resource Name          process session holds waits  process session holds waits
TX-000a000f-00001880        83     152     X             85     253           S
TX-00120017-000018cb        85     253     X             82     111           S
TX-00210009-00000cde        82     111     X             84     209           S
TX-001f001a-00000cde        84     209     X             83     152           S

session 152: DID 0001-0053-00005149     session 253: DID 0001-0055-000046C4
session 253: DID 0001-0055-000046C4     session 111: DID 0001-0052-0001929D
session 111: DID 0001-0052-0001929D     session 209: DID 0001-0054-000049EF
session 209: DID 0001-0054-000049EF     session 152: DID 0001-0053-00005149

Rows waited on:
  Session 152: no row
  Session 253: no row
  Session 111: no row
  Session 209: no row


 Session Wait History:
        elapsed time of 0.000029 sec since current wait
     0: waited for &#039;enq: TX - allocate ITL entry&#039;
...
[/sourcecode]
Best regards,
Martin]]></description>
		<content:encoded><![CDATA[<p>Hi Jonathan,</p>
<p>the same deadlock tree appears if the reason is ITL contention on heap table:</p>
<pre class="brush: plain; title: ; notranslate">
Deadlock graph:
                       ---------Blocker(s)--------  ---------Waiter(s)---------
Resource Name          process session holds waits  process session holds waits
TX-000a000f-00001880        83     152     X             85     253           S
TX-00120017-000018cb        85     253     X             82     111           S
TX-00210009-00000cde        82     111     X             84     209           S
TX-001f001a-00000cde        84     209     X             83     152           S

session 152: DID 0001-0053-00005149     session 253: DID 0001-0055-000046C4
session 253: DID 0001-0055-000046C4     session 111: DID 0001-0052-0001929D
session 111: DID 0001-0052-0001929D     session 209: DID 0001-0054-000049EF
session 209: DID 0001-0054-000049EF     session 152: DID 0001-0053-00005149

Rows waited on:
  Session 152: no row
  Session 253: no row
  Session 111: no row
  Session 209: no row


 Session Wait History:
        elapsed time of 0.000029 sec since current wait
     0: waited for 'enq: TX - allocate ITL entry'
...
</pre>
<p>Best regards,<br />
Martin</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jonathan Lewis</title>
		<link>http://jonathanlewis.wordpress.com/2011/04/08/deadlock/#comment-40408</link>
		<dc:creator><![CDATA[Jonathan Lewis]]></dc:creator>
		<pubDate>Sat, 23 Apr 2011 08:31:34 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=6169#comment-40408</guid>
		<description><![CDATA[&lt;em&gt;&quot;But whatever it is, I don’t think it is that terribly important, so I leave it as it is.&quot;&lt;/em&gt;

Good strategic choice - there are plenty of things which are interesting oddities, but once we have a good enough idea of what&#039;s happening it&#039;s often time to take a quick note and move on. I often find that after collecting &quot;partial solutions&quot; over a period of time the moment comes when three of four pieces of information happen to fit together and give me some insight into a bigger design issue.

In passing I ran the test one more time with wait state tracing enabled (and a change of distributed lock timeout) and every single PX slave dumped the following trace (with different process and session ids for the waiter, of course) after waiting 20 times on a 3-second TM/3 enqueue:

[sourcecode gutter=&quot;false&quot;]
DEADLOCK DETECTED ( ORA-00060 )
[Transaction Deadlock]
The following deadlock is not an ORACLE error. It is a
deadlock due to user error in the design of an application
or from issuing incorrect ad-hoc SQL. The following
information may aid in determining the deadlock:
Deadlock graph:
                       ---------Blocker(s)--------  ---------Waiter(s)---------
Resource Name          process session holds waits  process session holds waits
TM-000131f8-00000000        12      50     X             18      30          SX
session 50: DID 0001-000C-0000001B	session 30: DID 0001-000C-0000001B
Rows waited on:
Session 30: no row
Information on the OTHER waiting sessions:
End of information on OTHER waiting sessions.
Current SQL statement for this session:
INSERT INTO TESTSZ X
WITH X1 AS (SELECT /*+ PARALLEL(T,4) materialize */ 2000, K FROM TESTSZ T
WHERE I=1)
SELECT * FROM X1

[/sourcecode]]]></description>
		<content:encoded><![CDATA[<p><em>&#8220;But whatever it is, I don’t think it is that terribly important, so I leave it as it is.&#8221;</em></p>
<p>Good strategic choice &#8211; there are plenty of things which are interesting oddities, but once we have a good enough idea of what&#8217;s happening it&#8217;s often time to take a quick note and move on. I often find that after collecting &#8220;partial solutions&#8221; over a period of time the moment comes when three of four pieces of information happen to fit together and give me some insight into a bigger design issue.</p>
<p>In passing I ran the test one more time with wait state tracing enabled (and a change of distributed lock timeout) and every single PX slave dumped the following trace (with different process and session ids for the waiter, of course) after waiting 20 times on a 3-second TM/3 enqueue:</p>
<pre class="brush: plain; gutter: false; title: ; notranslate">
DEADLOCK DETECTED ( ORA-00060 )
[Transaction Deadlock]
The following deadlock is not an ORACLE error. It is a
deadlock due to user error in the design of an application
or from issuing incorrect ad-hoc SQL. The following
information may aid in determining the deadlock:
Deadlock graph:
                       ---------Blocker(s)--------  ---------Waiter(s)---------
Resource Name          process session holds waits  process session holds waits
TM-000131f8-00000000        12      50     X             18      30          SX
session 50: DID 0001-000C-0000001B	session 30: DID 0001-000C-0000001B
Rows waited on:
Session 30: no row
Information on the OTHER waiting sessions:
End of information on OTHER waiting sessions.
Current SQL statement for this session:
INSERT INTO TESTSZ X
WITH X1 AS (SELECT /*+ PARALLEL(T,4) materialize */ 2000, K FROM TESTSZ T
WHERE I=1)
SELECT * FROM X1

</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Stefan</title>
		<link>http://jonathanlewis.wordpress.com/2011/04/08/deadlock/#comment-40397</link>
		<dc:creator><![CDATA[Stefan]]></dc:creator>
		<pubDate>Fri, 22 Apr 2011 12:08:44 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=6169#comment-40397</guid>
		<description><![CDATA[Thanks for the answer. 
It&#039;s funny, how I did not look any further, once I found a perceived consistent explanation.
But I should have noticed, in a very simple test, standard deadlock detection already signals after 3 seconds. 

But now, out of curiosity I changed on my test system the setting of distributed_lock_timeout parameter and retested after instance bounce.

On 10.2.0.4, parameter change had no effect:

[sourcecode]
SQL&gt; select version from v$instance;

VERSION
----------
10.2.0.4.0

SQL&gt; select name, value from v$parameter where name=&#039;distributed_lock_timeout&#039;;

NAME                      VALUE
------------------------- -----
distributed_lock_timeout  180


SQL&gt; LOCK TABLE TESTSZ IN EXCLUSIVE MODE;

Tabelle(n) wurde(n) gesperrt.

SQL&gt; set timing on
SQL&gt; INSERT INTO TESTSZ X
  2   WITH X1 AS
  3    (SELECT /*+ PARALLEL(T,4) MATERIALIZE*/ 2000, K FROM TESTSZ T WHERE I=1)
  4   SELECT * FROM X1;
INSERT INTO TESTSZ X
*
FEHLER in Zeile 1:
ORA-12801: error signaled in parallel query server P000
ORA-00060: deadlock detected while waiting for resource

Abgelaufen: 00:01:04.66
[/sourcecode]

So there must be some more to this, than I currently undertstand. Bu whatever it is, I don&#039;t think it is that terribly important, so I leave it as it is.]]></description>
		<content:encoded><![CDATA[<p>Thanks for the answer.<br />
It&#8217;s funny, how I did not look any further, once I found a perceived consistent explanation.<br />
But I should have noticed, in a very simple test, standard deadlock detection already signals after 3 seconds. </p>
<p>But now, out of curiosity I changed on my test system the setting of distributed_lock_timeout parameter and retested after instance bounce.</p>
<p>On 10.2.0.4, parameter change had no effect:</p>
<pre class="brush: plain; title: ; notranslate">
SQL&gt; select version from v$instance;

VERSION
----------
10.2.0.4.0

SQL&gt; select name, value from v$parameter where name='distributed_lock_timeout';

NAME                      VALUE
------------------------- -----
distributed_lock_timeout  180


SQL&gt; LOCK TABLE TESTSZ IN EXCLUSIVE MODE;

Tabelle(n) wurde(n) gesperrt.

SQL&gt; set timing on
SQL&gt; INSERT INTO TESTSZ X
  2   WITH X1 AS
  3    (SELECT /*+ PARALLEL(T,4) MATERIALIZE*/ 2000, K FROM TESTSZ T WHERE I=1)
  4   SELECT * FROM X1;
INSERT INTO TESTSZ X
*
FEHLER in Zeile 1:
ORA-12801: error signaled in parallel query server P000
ORA-00060: deadlock detected while waiting for resource

Abgelaufen: 00:01:04.66
</pre>
<p>So there must be some more to this, than I currently undertstand. Bu whatever it is, I don&#8217;t think it is that terribly important, so I leave it as it is.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jonathan Lewis</title>
		<link>http://jonathanlewis.wordpress.com/2011/04/08/deadlock/#comment-40383</link>
		<dc:creator><![CDATA[Jonathan Lewis]]></dc:creator>
		<pubDate>Wed, 20 Apr 2011 14:21:04 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=6169#comment-40383</guid>
		<description><![CDATA[Stefan,

Thanks for that, and sorry about the delay in follow.

The deadlock message looks as if it&#039;s not the right one - the wait when I copied your test case was about 60 seconds (a little longer) which suggests it&#039;s actually an &quot;assumed distributed deadlock&quot; (which is consistent with the whole parallel DML operation).  Commenting out your &quot;lock table in exclusive mode&quot; obviously avoided the deadlock.

As far as I know, once you&#039;ve covered the usual FK sinners, it&#039;s only oddities of table locking for parallel, distributed, or autonomous transactions that can cause TM deadlocks.]]></description>
		<content:encoded><![CDATA[<p>Stefan,</p>
<p>Thanks for that, and sorry about the delay in follow.</p>
<p>The deadlock message looks as if it&#8217;s not the right one &#8211; the wait when I copied your test case was about 60 seconds (a little longer) which suggests it&#8217;s actually an &#8220;assumed distributed deadlock&#8221; (which is consistent with the whole parallel DML operation).  Commenting out your &#8220;lock table in exclusive mode&#8221; obviously avoided the deadlock.</p>
<p>As far as I know, once you&#8217;ve covered the usual FK sinners, it&#8217;s only oddities of table locking for parallel, distributed, or autonomous transactions that can cause TM deadlocks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: TM enqueues and deadlock with one user session &#171; perfexpert2</title>
		<link>http://jonathanlewis.wordpress.com/2011/04/08/deadlock/#comment-40353</link>
		<dc:creator><![CDATA[TM enqueues and deadlock with one user session &#171; perfexpert2]]></dc:creator>
		<pubDate>Sat, 16 Apr 2011 17:37:07 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=6169#comment-40353</guid>
		<description><![CDATA[[...] time now, I have been thinking about writing some blog items, but never did. A recent blog entry on http://jonathanlewis.wordpress.com/2011/04/08/deadlock prompted me to give it a [...]]]></description>
		<content:encoded><![CDATA[<p>[...] time now, I have been thinking about writing some blog items, but never did. A recent blog entry on <a href="http://jonathanlewis.wordpress.com/2011/04/08/deadlock" rel="nofollow">http://jonathanlewis.wordpress.com/2011/04/08/deadlock</a> prompted me to give it a [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Log Buffer #216, A Carnival of the Vanities for DBAs &#124; The Pythian Blog</title>
		<link>http://jonathanlewis.wordpress.com/2011/04/08/deadlock/#comment-40339</link>
		<dc:creator><![CDATA[Log Buffer #216, A Carnival of the Vanities for DBAs &#124; The Pythian Blog]]></dc:creator>
		<pubDate>Fri, 15 Apr 2011 11:12:10 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=6169#comment-40339</guid>
		<description><![CDATA[[...] Deadlocks are such an important topic that they routinely attract attention of world&#8217;s best professional and Jonathan Lewis is no exception. [...]]]></description>
		<content:encoded><![CDATA[<p>[...] Deadlocks are such an important topic that they routinely attract attention of world&#8217;s best professional and Jonathan Lewis is no exception. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Stefan</title>
		<link>http://jonathanlewis.wordpress.com/2011/04/08/deadlock/#comment-40295</link>
		<dc:creator><![CDATA[Stefan]]></dc:creator>
		<pubDate>Sat, 09 Apr 2011 09:06:49 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=6169#comment-40295</guid>
		<description><![CDATA[TM-enqueus for foreign key locking seems to be a well known fact. What I personally would like to know, what other reasons can cause TM-Locks. 
A few times already I had issues with them, not involving foreign keys. 


Sligtly more on topic, did anyone know, that a single user connected session can cause a deadlock?

on 10.2.0.3 and 11.1.0.7 verified:
[sourcecode]
DROP TABLE TESTSZ;
CREATE TABLE TESTSZ
( I NUMBER,
  K VARCHAR2(50));
INSERT INTO TESTSZ
SELECT MOD(ROWNUM,1000), LPAD(&#039;X&#039;,40,&#039;Y&#039;) FROM DUAL CONNECT BY ROWNUM &lt; 1000000; 
COMMIT;
LOCK TABLE TESTSZ IN EXCLUSIVE MODE;
INSERT INTO TESTSZ X
WITH X1 AS (SELECT /*+ no_PARALLEL(T) MATERIALIZE*/ 2000, K FROM TESTSZ T
       WHERE I=1)
SELECT * FROM X1;
rollback;
LOCK TABLE TESTSZ IN EXCLUSIVE MODE;
set timing on
INSERT INTO TESTSZ X
WITH X1 AS (SELECT /*+ PARALLEL(T,4) MATERIALIZE*/ 2000, K FROM TESTSZ T
       WHERE I=1)
SELECT * FROM X1;
rollback; 
[/sourcecode]


Result of the last insert statement:
[sourcecode]
INSERT INTO TESTSZ X
*
FEHLER in Zeile 1:
ORA-12801: error signaled in parallel query server P000
ORA-00060: deadlock detected while waiting for resource
[/sourcecode]


Before anyone complains there are more than one session involved, 
yes, but the importance is only one &quot;user&quot; connected session.

Moving back to TM locks, in the case above with the factored subquery 
in combination with parallel query, the deadlock occurs while the sessions 
are trying to get TM-locks.

[sourcecode]
SID	PROGRAM				LAST_CALL_ET	BLOCKING_SESSION	EVENT			SECONDS_IN_WAIT	
116	sqlplus.exe			48					PX Deq: Parse Reply	3	WAITING	
117	oracle@cyber-ora10 (P005)	48					PX Deq: Execution Msg	3	WAITING	
128	oracle@cyber-ora10 (P004)	48					PX Deq: Execution Msg	3	WAITING	
115	oracle@cyber-ora10 (P003)	48					PX Deq: Execution Msg	3	WAITING	
129	oracle@cyber-ora10 (P002)	48		116			enq: TM - contention	48	WAITING		
120	oracle@cyber-ora10 (P001)	48		116			enq: TM - contention	48	WAITING		
136	oracle@cyber-ora10 (P000)	48		116			enq: TM - contention	48	WAITING	
	
[/sourcecode]

To finish, Oracle support aggreed, that this is not supposed to happen. The workaround is to use the inline hint.]]></description>
		<content:encoded><![CDATA[<p>TM-enqueus for foreign key locking seems to be a well known fact. What I personally would like to know, what other reasons can cause TM-Locks.<br />
A few times already I had issues with them, not involving foreign keys. </p>
<p>Sligtly more on topic, did anyone know, that a single user connected session can cause a deadlock?</p>
<p>on 10.2.0.3 and 11.1.0.7 verified:</p>
<pre class="brush: plain; title: ; notranslate">
DROP TABLE TESTSZ;
CREATE TABLE TESTSZ
( I NUMBER,
  K VARCHAR2(50));
INSERT INTO TESTSZ
SELECT MOD(ROWNUM,1000), LPAD('X',40,'Y') FROM DUAL CONNECT BY ROWNUM &amp;lt; 1000000; 
COMMIT;
LOCK TABLE TESTSZ IN EXCLUSIVE MODE;
INSERT INTO TESTSZ X
WITH X1 AS (SELECT /*+ no_PARALLEL(T) MATERIALIZE*/ 2000, K FROM TESTSZ T
       WHERE I=1)
SELECT * FROM X1;
rollback;
LOCK TABLE TESTSZ IN EXCLUSIVE MODE;
set timing on
INSERT INTO TESTSZ X
WITH X1 AS (SELECT /*+ PARALLEL(T,4) MATERIALIZE*/ 2000, K FROM TESTSZ T
       WHERE I=1)
SELECT * FROM X1;
rollback; 
</pre>
<p>Result of the last insert statement:</p>
<pre class="brush: plain; title: ; notranslate">
INSERT INTO TESTSZ X
*
FEHLER in Zeile 1:
ORA-12801: error signaled in parallel query server P000
ORA-00060: deadlock detected while waiting for resource
</pre>
<p>Before anyone complains there are more than one session involved,<br />
yes, but the importance is only one &quot;user&quot; connected session.</p>
<p>Moving back to TM locks, in the case above with the factored subquery<br />
in combination with parallel query, the deadlock occurs while the sessions<br />
are trying to get TM-locks.</p>
<pre class="brush: plain; title: ; notranslate">
SID	PROGRAM				LAST_CALL_ET	BLOCKING_SESSION	EVENT			SECONDS_IN_WAIT	
116	sqlplus.exe			48					PX Deq: Parse Reply	3	WAITING	
117	oracle@cyber-ora10 (P005)	48					PX Deq: Execution Msg	3	WAITING	
128	oracle@cyber-ora10 (P004)	48					PX Deq: Execution Msg	3	WAITING	
115	oracle@cyber-ora10 (P003)	48					PX Deq: Execution Msg	3	WAITING	
129	oracle@cyber-ora10 (P002)	48		116			enq: TM - contention	48	WAITING		
120	oracle@cyber-ora10 (P001)	48		116			enq: TM - contention	48	WAITING		
136	oracle@cyber-ora10 (P000)	48		116			enq: TM - contention	48	WAITING	
	
</pre>
<p>To finish, Oracle support aggreed, that this is not supposed to happen. The workaround is to use the inline hint.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
