<?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/08/29/deadlock-2/feed/" rel="self" type="application/rss+xml" />
	<link>http://jonathanlewis.wordpress.com/2011/08/29/deadlock-2/</link>
	<description>Just another Oracle weblog</description>
	<lastBuildDate>Wed, 19 Jun 2013 09:52:54 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: Jonathan Lewis</title>
		<link>http://jonathanlewis.wordpress.com/2011/08/29/deadlock-2/#comment-42672</link>
		<dc:creator><![CDATA[Jonathan Lewis]]></dc:creator>
		<pubDate>Mon, 28 Nov 2011 17:26:06 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=7018#comment-42672</guid>
		<description><![CDATA[I&#039;ve just had an exchange of email with Tom Kyte about a thread on AskTom that quoted the previous comment, specifically the bit:

&lt;blockquote&gt;&lt;em&gt;
&quot;As far as I know if there are no free ITL entries in a leaf block the process that wants one will simply intitiate a leaf block split.&quot;
&lt;/em&gt;&lt;/blockquote&gt;

When I wrote this I was writing in the context of the question, of course, which was all about inserting rows, not about updating or deleting rows; so when Tom emailed me about it my immediate reply was that it didn&#039;t apply to deletes or updates (and rememmber that an update is implemented at the index level as a delete followed by an insert).

However, as I sat down to write a short note to add to this blog, I suddenly realised that I wasn&#039;t sure that I had told Tom the truth - so I did a quick search of my working directory for any scripts with the words &lt;em&gt;&quot;index split delete&quot;&lt;/em&gt;, and found a script called (appropriately enough) ind_split_del.sql that I had written a few years ago to demonstrate a couple of variations of how a block split could occur during a delete that wasn&#039;t able to find or create an ITL entry in the leaf block.  (I may write this up some day - it&#039;s another of the edge cases where an index can become larger than it should because of concurrent activity.)

If you&#039;re wondering how Oracle can split a leaf block when it can&#039;t find an ITL to change the block, by the way, you need to know that Oracle reserves the first ITL entry in a leaf block for &quot;service&quot; transactions - viz: block splits. (See &lt;a href=&quot;http://jonathanlewis.wordpress.com/2009/07/24/iq2-answers/&quot; rel=&quot;nofollow&quot;&gt;&lt;em&gt;&lt;strong&gt;this blog note&lt;/strong&gt;&lt;/em&gt;&lt;/a&gt; for a couple of comments about service transactions and service ITLs as they relate to branch blocks)

This does leave unanswered the question of how you can get ITL waits on an index - but I haven&#039;t tested many variations of deletions, or mixing inserts and deletes; and it&#039;s always possible that the waits appear if two deletes start on the same leaf block at the same time and both need to split the block. There may be cases were the waits relate to branch block contention if two sessions try to split two different leaf blocks under the same branch at the same time. Given that we know what it means to wait for an ITL, it&#039;s relatively easy to come up with scenarios where they may occur - unfortunately it takes time (and sometimes a lot of patience) to create and run tests for those scenarios.
]]></description>
		<content:encoded><![CDATA[<p>I&#8217;ve just had an exchange of email with Tom Kyte about a thread on AskTom that quoted the previous comment, specifically the bit:</p>
<blockquote><p><em><br />
&#8220;As far as I know if there are no free ITL entries in a leaf block the process that wants one will simply intitiate a leaf block split.&#8221;<br />
</em></p></blockquote>
<p>When I wrote this I was writing in the context of the question, of course, which was all about inserting rows, not about updating or deleting rows; so when Tom emailed me about it my immediate reply was that it didn&#8217;t apply to deletes or updates (and rememmber that an update is implemented at the index level as a delete followed by an insert).</p>
<p>However, as I sat down to write a short note to add to this blog, I suddenly realised that I wasn&#8217;t sure that I had told Tom the truth &#8211; so I did a quick search of my working directory for any scripts with the words <em>&#8220;index split delete&#8221;</em>, and found a script called (appropriately enough) ind_split_del.sql that I had written a few years ago to demonstrate a couple of variations of how a block split could occur during a delete that wasn&#8217;t able to find or create an ITL entry in the leaf block.  (I may write this up some day &#8211; it&#8217;s another of the edge cases where an index can become larger than it should because of concurrent activity.)</p>
<p>If you&#8217;re wondering how Oracle can split a leaf block when it can&#8217;t find an ITL to change the block, by the way, you need to know that Oracle reserves the first ITL entry in a leaf block for &#8220;service&#8221; transactions &#8211; viz: block splits. (See <a href="http://jonathanlewis.wordpress.com/2009/07/24/iq2-answers/" rel="nofollow"><em><strong>this blog note</strong></em></a> for a couple of comments about service transactions and service ITLs as they relate to branch blocks)</p>
<p>This does leave unanswered the question of how you can get ITL waits on an index &#8211; but I haven&#8217;t tested many variations of deletions, or mixing inserts and deletes; and it&#8217;s always possible that the waits appear if two deletes start on the same leaf block at the same time and both need to split the block. There may be cases were the waits relate to branch block contention if two sessions try to split two different leaf blocks under the same branch at the same time. Given that we know what it means to wait for an ITL, it&#8217;s relatively easy to come up with scenarios where they may occur &#8211; unfortunately it takes time (and sometimes a lot of patience) to create and run tests for those scenarios.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jonathan Lewis</title>
		<link>http://jonathanlewis.wordpress.com/2011/08/29/deadlock-2/#comment-42348</link>
		<dc:creator><![CDATA[Jonathan Lewis]]></dc:creator>
		<pubDate>Sun, 13 Nov 2011 12:36:33 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=7018#comment-42348</guid>
		<description><![CDATA[Balaji,

If all you were doing was inserting rows into a child table with an enabled foreign key that was protected by a suitable index, I wouldn&#039;t have expected to see ITL waits. As far as I know if there are no free ITL entries in a leaf block the process that wants one will simply intitiate a leaf block split. I could probably come up with a couple of scenarios to check if necessary - e.g. two sessions wanting to insert for the same parent key simultaneously when there are no free ITLs (though I might expect a buffer busy wait or &quot;enq: TX - index contention&quot;); or two leaf blocks under the same branch block having to split simuiltanously and causing contention for the branch ITL entry (although again I think I&#039;d expect &quot;Enq: TX - index contention&quot;).

I haven&#039;t tested FKs with reverse key indexes - I can think on no reason why they would cause any problems. It&#039;s easy to test though, and you could apply the test case to different versions of Oracle because it&#039;s often the case that a detail that ought to work simply doesn&#039;t work on the first release. (e.g. you couldn&#039;t do index fast full scans on bitmap indexes in the first release where index fast full scans appeared.)]]></description>
		<content:encoded><![CDATA[<p>Balaji,</p>
<p>If all you were doing was inserting rows into a child table with an enabled foreign key that was protected by a suitable index, I wouldn&#8217;t have expected to see ITL waits. As far as I know if there are no free ITL entries in a leaf block the process that wants one will simply intitiate a leaf block split. I could probably come up with a couple of scenarios to check if necessary &#8211; e.g. two sessions wanting to insert for the same parent key simultaneously when there are no free ITLs (though I might expect a buffer busy wait or &#8220;enq: TX &#8211; index contention&#8221;); or two leaf blocks under the same branch block having to split simuiltanously and causing contention for the branch ITL entry (although again I think I&#8217;d expect &#8220;Enq: TX &#8211; index contention&#8221;).</p>
<p>I haven&#8217;t tested FKs with reverse key indexes &#8211; I can think on no reason why they would cause any problems. It&#8217;s easy to test though, and you could apply the test case to different versions of Oracle because it&#8217;s often the case that a detail that ought to work simply doesn&#8217;t work on the first release. (e.g. you couldn&#8217;t do index fast full scans on bitmap indexes in the first release where index fast full scans appeared.)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Balaji</title>
		<link>http://jonathanlewis.wordpress.com/2011/08/29/deadlock-2/#comment-42093</link>
		<dc:creator><![CDATA[Balaji]]></dc:creator>
		<pubDate>Sun, 16 Oct 2011 17:00:10 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=7018#comment-42093</guid>
		<description><![CDATA[What would be a reason for ITL waits on an index segment?. Especially if the index is on a child table on a FK constraint column.
This ITL waits showingup while concurrent inserts into the child table.

Also can FK indexes can be reverse key? Would that have any negative impact (TM locks ) 

Thanks
Balaji.]]></description>
		<content:encoded><![CDATA[<p>What would be a reason for ITL waits on an index segment?. Especially if the index is on a child table on a FK constraint column.<br />
This ITL waits showingup while concurrent inserts into the child table.</p>
<p>Also can FK indexes can be reverse key? Would that have any negative impact (TM locks ) </p>
<p>Thanks<br />
Balaji.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Deadlock &#8211; All Things Oracle</title>
		<link>http://jonathanlewis.wordpress.com/2011/08/29/deadlock-2/#comment-41663</link>
		<dc:creator><![CDATA[Deadlock &#8211; All Things Oracle]]></dc:creator>
		<pubDate>Thu, 08 Sep 2011 17:10:10 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=7018#comment-41663</guid>
		<description><![CDATA[[...] From Jonathan Lewis&#8217; Oracle Scratchpad blog. [...]]]></description>
		<content:encoded><![CDATA[<p>[...] From Jonathan Lewis&#8217; Oracle Scratchpad blog. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jonathan Lewis</title>
		<link>http://jonathanlewis.wordpress.com/2011/08/29/deadlock-2/#comment-41597</link>
		<dc:creator><![CDATA[Jonathan Lewis]]></dc:creator>
		<pubDate>Thu, 01 Sep 2011 16:17:58 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=7018#comment-41597</guid>
		<description><![CDATA[Mohamed,
Now corrected. Thanks]]></description>
		<content:encoded><![CDATA[<p>Mohamed,<br />
Now corrected. Thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jonathan Lewis</title>
		<link>http://jonathanlewis.wordpress.com/2011/08/29/deadlock-2/#comment-41596</link>
		<dc:creator><![CDATA[Jonathan Lewis]]></dc:creator>
		<pubDate>Thu, 01 Sep 2011 16:16:00 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=7018#comment-41596</guid>
		<description><![CDATA[Flado, correct - session 2 is the first to start waiting, and it is the one that will raise the deadlock. (Now corrected.)

I would like to think that the &quot;1&quot; was just a case of missing the key while typing, and not noticing the error.
Technically I suppose it is possible for the two waiters to start running in the wrong order - but since they go off the run queue in order they will presumable go back on the run queue in order: but on a multi-CPU machine is there one run queue that services all CPUs or one runqueue per CPU ? In the latter case if process one goes onto the run queue of CPU A and process two goes onto the run queue of CPU B then I guess process two could get to the top of its run queue before process one.]]></description>
		<content:encoded><![CDATA[<p>Flado, correct &#8211; session 2 is the first to start waiting, and it is the one that will raise the deadlock. (Now corrected.)</p>
<p>I would like to think that the &#8220;1&#8243; was just a case of missing the key while typing, and not noticing the error.<br />
Technically I suppose it is possible for the two waiters to start running in the wrong order &#8211; but since they go off the run queue in order they will presumable go back on the run queue in order: but on a multi-CPU machine is there one run queue that services all CPUs or one runqueue per CPU ? In the latter case if process one goes onto the run queue of CPU A and process two goes onto the run queue of CPU B then I guess process two could get to the top of its run queue before process one.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Houri Mohamed</title>
		<link>http://jonathanlewis.wordpress.com/2011/08/29/deadlock-2/#comment-41583</link>
		<dc:creator><![CDATA[Houri Mohamed]]></dc:creator>
		<pubDate>Wed, 31 Aug 2011 08:20:53 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=7018#comment-41583</guid>
		<description><![CDATA[It is the session(session 2) doing the insert that will time out and will report the deadlock error

[sourcecode language=&quot;sql&quot;]

mhouri.world&gt; insert into child values (1,2,&#039;Sally&#039;);
insert into child values (1,2,&#039;Sally&#039;)
            *
ERROR at line 1:
ORA-00060: deadlock detected while waiting for resource
[/sourcecode]

Best regards]]></description>
		<content:encoded><![CDATA[<p>It is the session(session 2) doing the insert that will time out and will report the deadlock error</p>
<pre class="brush: sql; title: ; notranslate">

mhouri.world&gt; insert into child values (1,2,'Sally');
insert into child values (1,2,'Sally')
            *
ERROR at line 1:
ORA-00060: deadlock detected while waiting for resource
</pre>
<p>Best regards</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Flado</title>
		<link>http://jonathanlewis.wordpress.com/2011/08/29/deadlock-2/#comment-41571</link>
		<dc:creator><![CDATA[Flado]]></dc:creator>
		<pubDate>Tue, 30 Aug 2011 10:31:34 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=7018#comment-41571</guid>
		<description><![CDATA[&gt; ... session 1 (the first to start waiting) ...
Isn&#039;t session 2 the first to start waiting? 
And is this deterministic - the first session to start waiting will be the one detecting the deadlock? As far as I know (from somewhere), every session timing out on an enqueue wait will check for a deadlock before going to sleep again. Now, in almost all cases the first session to start waiting will be the first to time-out, but there&#039;s a difference between being runnable and actually running, so it seems possible that the second session to start waiting might end up being the one detecting the deadlock. 
Not that this matters for the topic of the post, I&#039;m just curious.]]></description>
		<content:encoded><![CDATA[<p>&gt; &#8230; session 1 (the first to start waiting) &#8230;<br />
Isn&#8217;t session 2 the first to start waiting?<br />
And is this deterministic &#8211; the first session to start waiting will be the one detecting the deadlock? As far as I know (from somewhere), every session timing out on an enqueue wait will check for a deadlock before going to sleep again. Now, in almost all cases the first session to start waiting will be the first to time-out, but there&#8217;s a difference between being runnable and actually running, so it seems possible that the second session to start waiting might end up being the one detecting the deadlock.<br />
Not that this matters for the topic of the post, I&#8217;m just curious.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
