<?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: Lock Watching &#8211; What is Wrong with this SQL Statement?</title>
	<atom:link href="http://hoopercharles.wordpress.com/2010/06/03/lock-watching-what-is-wrong-with-this-sql-statement/feed/" rel="self" type="application/rss+xml" />
	<link>http://hoopercharles.wordpress.com/2010/06/03/lock-watching-what-is-wrong-with-this-sql-statement/</link>
	<description>Miscellaneous Random Oracle Topics: Stop, Think, ... Understand</description>
	<lastBuildDate>Thu, 23 May 2013 04:02:42 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: Charles Hooper</title>
		<link>http://hoopercharles.wordpress.com/2010/06/03/lock-watching-what-is-wrong-with-this-sql-statement/#comment-1351</link>
		<dc:creator><![CDATA[Charles Hooper]]></dc:creator>
		<pubDate>Fri, 11 Jun 2010 14:31:34 +0000</pubDate>
		<guid isPermaLink="false">http://hoopercharles.wordpress.com/?p=2529#comment-1351</guid>
		<description><![CDATA[I did not know if anyone would catch that Metalink quote - more than one Metalink article repeated that mistake regarding ROW_WAIT_ROW#.  Someone should file a bug report with Metalink.  :-)

My test case showing that ROW_WAIT_ROW# is populated even when there is no deadlock, and in some cases when ROW_WAIT_OBJ# is shown as -1, may be found in this blog article:
http://hoopercharles.wordpress.com/2009/12/06/enqueue-experimentations/]]></description>
		<content:encoded><![CDATA[<p>I did not know if anyone would catch that Metalink quote &#8211; more than one Metalink article repeated that mistake regarding ROW_WAIT_ROW#.  Someone should file a bug report with Metalink.  <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>My test case showing that ROW_WAIT_ROW# is populated even when there is no deadlock, and in some cases when ROW_WAIT_OBJ# is shown as -1, may be found in this blog article:<br />
<a href="http://hoopercharles.wordpress.com/2009/12/06/enqueue-experimentations/" rel="nofollow">http://hoopercharles.wordpress.com/2009/12/06/enqueue-experimentations/</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Flado</title>
		<link>http://hoopercharles.wordpress.com/2010/06/03/lock-watching-what-is-wrong-with-this-sql-statement/#comment-1350</link>
		<dc:creator><![CDATA[Flado]]></dc:creator>
		<pubDate>Fri, 11 Jun 2010 14:12:49 +0000</pubDate>
		<guid isPermaLink="false">http://hoopercharles.wordpress.com/?p=2529#comment-1350</guid>
		<description><![CDATA[Definitely OBJECT_ID. This

[sourcecode]
drop table t;
create table t (id) 
partition by list (id)
(partition tid1 values(1), partition tjunk values (default))
as select 1 from dual;
alter table t move partition tid1;
select id from t where id=1 for update;
with lo as (select /*+ materialize */ object_id from v$locked_object)
select do.object_name, do.object_type, do.object_id, do.data_object_id, lo.object_id
from dba_objects do, lo
where do.object_id=lo.object_id
   or do.data_object_id=lo.object_id;
[/sourcecode]
outputs this (in SQL Developer):
[sourcecode]
drop table t succeeded.
create table succeeded.
alter table t succeeded.
ID                     
------- 
1       

1 rows selected

OBJECT_NAME        OBJECT_TYPE         OBJECT_ID              DATA_OBJECT_ID         OBJECT_ID              
------------------ ------------------- ---------------------- ---------------------- ---------------------- 
T                  TABLE PARTITION     168031                 168033                 168031                 
T                  TABLE               168030                                        168030                 

2 rows selected

[/sourcecode]

The version is 10.2.0.3, although it shouldn&#039;t matter much.
ROW_WAIT_ROW# definitely gets populated for normal lock waits - I&#039;ve been using scripts depending on it (to construct a ROWID and select the row, of course) for ages and haven&#039;t noticed any wrong or missing results so far. Got to check what does ROW_WAIT_OBJ# contain, though: DBMS_ROWID.rowid_create() wants - and DBMS_ROWID.rowid_object() returns - a DATA_OBJECT_ID.

Thanks!
Flado]]></description>
		<content:encoded><![CDATA[<p>Definitely OBJECT_ID. This</p>
<pre class="brush: plain; title: ; notranslate">
drop table t;
create table t (id) 
partition by list (id)
(partition tid1 values(1), partition tjunk values (default))
as select 1 from dual;
alter table t move partition tid1;
select id from t where id=1 for update;
with lo as (select /*+ materialize */ object_id from v$locked_object)
select do.object_name, do.object_type, do.object_id, do.data_object_id, lo.object_id
from dba_objects do, lo
where do.object_id=lo.object_id
   or do.data_object_id=lo.object_id;
</pre>
<p>outputs this (in SQL Developer):</p>
<pre class="brush: plain; title: ; notranslate">
drop table t succeeded.
create table succeeded.
alter table t succeeded.
ID                     
------- 
1       

1 rows selected

OBJECT_NAME        OBJECT_TYPE         OBJECT_ID              DATA_OBJECT_ID         OBJECT_ID              
------------------ ------------------- ---------------------- ---------------------- ---------------------- 
T                  TABLE PARTITION     168031                 168033                 168031                 
T                  TABLE               168030                                        168030                 

2 rows selected

</pre>
<p>The version is 10.2.0.3, although it shouldn&#8217;t matter much.<br />
ROW_WAIT_ROW# definitely gets populated for normal lock waits &#8211; I&#8217;ve been using scripts depending on it (to construct a ROWID and select the row, of course) for ages and haven&#8217;t noticed any wrong or missing results so far. Got to check what does ROW_WAIT_OBJ# contain, though: DBMS_ROWID.rowid_create() wants &#8211; and DBMS_ROWID.rowid_object() returns &#8211; a DATA_OBJECT_ID.</p>
<p>Thanks!<br />
Flado</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Charles Hooper</title>
		<link>http://hoopercharles.wordpress.com/2010/06/03/lock-watching-what-is-wrong-with-this-sql-statement/#comment-1349</link>
		<dc:creator><![CDATA[Charles Hooper]]></dc:creator>
		<pubDate>Fri, 11 Jun 2010 12:38:26 +0000</pubDate>
		<guid isPermaLink="false">http://hoopercharles.wordpress.com/?p=2529#comment-1349</guid>
		<description><![CDATA[Good question.  If you see something wrong, please feel free to point out the problem, even if it is nitpicking - this blog article is asking what is wrong with this SQL statement.  Minor problems repeated frequently enough can become bigger problems at a later time.

I found a couple of interesting articles on Metalink related to locks:
Metalink Doc ID 202390.1 &quot;Payables Invoice Processing Troubleshooting Guide&quot; uses object_id 
Metalink Doc ID 478027.1 &quot;How to Troubleshoot Hangs on Unix&quot; uses object_id
Metalink Doc ID 117316.1 &quot;ORA-0054: When Dropping or Truncating Table, When Creating or Rebuilding Index&quot; uses object_id
Metalink Doc ID 821691.1 &quot;ORA-00054: resource busy and acquire with NOWAIT error while running Planning ODS Load&quot; uses object_id
Metalink Doc ID 748144.1 &quot;How To Troubleshoot And Resolve Service Request And Task Locking Issues Within CRM&quot; uses object_id
Metalink Doc ID 198150.1 &quot;How To Indentify The Row Which is Locked By an Other User&#039;s Session&quot; uses object_id - interesting, states &quot;ROW_WAIT_ROW# in v$sesssion will only be populated when there is a deadlock
situation occurring.&quot; - I wonder if I have a counter-example?
Metalink Doc ID 390207.1 &quot;Unexpected Behaviour Of Lock Table And Fine Grained Access Control&quot; uses object_id
Metalink Doc ID 15476.1 &quot;FAQ about Detecting and Resolving Locking Conflicts&quot; - does not show how to join the views, but an interesting document
Metalink Doc ID 398519.1 &quot;Detecting Blocking Sessions in RAC and non-RAC (Enqueue Locks) Environments&quot; - BLOCK &quot;value is always 2 in RAC environments unless there is local conflict&quot; - joins ID1 of V$LOCK to DBA_OBJECTS.OBJECT_ID
Metalink Doc ID 102925.1 &quot;Tracing sessions: waiting on an enqueue&quot; - &quot;For the lock type TM (table lock), column ID1 is the object_id (or the data_object_id) for that table (could be joined with DBA_OBJECTS).&quot; - seems to be unclear which column.
Metalink Doc ID 62354.1 &quot;TX Transaction locks - Example wait scenarios&quot; - avoids the question.
Metalink Doc ID 43724.1 &quot;VIEW: &#039;V$LOCKED_OBJECT&#039; Reference Note&quot; - &quot;This view lists all locks acquired by every transaction on the system.&quot; - &quot;OBJECT_ID - Object ID being locked&quot;

&lt;pre&gt;
SQL&gt; DESC DBA_OBJECTS
 Name
 ------------------------
 OWNER
 OBJECT_NAME
 SUBOBJECT_NAME
 OBJECT_ID
 DATA_OBJECT_ID
 OBJECT_TYPE
 CREATED
 LAST_DDL_TIME
 TIMESTAMP
 STATUS
 TEMPORARY
 GENERATED
 SECONDARY

SQL&gt; DESC V$LOCKED_OBJECT
 Name
 ------------------------
 XIDUSN
 XIDSLOT
 XIDSQN
 OBJECT_ID
 SESSION_ID
 ORACLE_USERNAME
 OS_USER_NAME
 PROCESS
 LOCKED_MODE
&lt;/pre&gt;

It looks like the only option to join these two views is OBJECT_ID.  Now maybe someone can help explain what kinds of problems that might cause.]]></description>
		<content:encoded><![CDATA[<p>Good question.  If you see something wrong, please feel free to point out the problem, even if it is nitpicking &#8211; this blog article is asking what is wrong with this SQL statement.  Minor problems repeated frequently enough can become bigger problems at a later time.</p>
<p>I found a couple of interesting articles on Metalink related to locks:<br />
Metalink Doc ID 202390.1 &#8220;Payables Invoice Processing Troubleshooting Guide&#8221; uses object_id<br />
Metalink Doc ID 478027.1 &#8220;How to Troubleshoot Hangs on Unix&#8221; uses object_id<br />
Metalink Doc ID 117316.1 &#8220;ORA-0054: When Dropping or Truncating Table, When Creating or Rebuilding Index&#8221; uses object_id<br />
Metalink Doc ID 821691.1 &#8220;ORA-00054: resource busy and acquire with NOWAIT error while running Planning ODS Load&#8221; uses object_id<br />
Metalink Doc ID 748144.1 &#8220;How To Troubleshoot And Resolve Service Request And Task Locking Issues Within CRM&#8221; uses object_id<br />
Metalink Doc ID 198150.1 &#8220;How To Indentify The Row Which is Locked By an Other User&#8217;s Session&#8221; uses object_id &#8211; interesting, states &#8220;ROW_WAIT_ROW# in v$sesssion will only be populated when there is a deadlock<br />
situation occurring.&#8221; &#8211; I wonder if I have a counter-example?<br />
Metalink Doc ID 390207.1 &#8220;Unexpected Behaviour Of Lock Table And Fine Grained Access Control&#8221; uses object_id<br />
Metalink Doc ID 15476.1 &#8220;FAQ about Detecting and Resolving Locking Conflicts&#8221; &#8211; does not show how to join the views, but an interesting document<br />
Metalink Doc ID 398519.1 &#8220;Detecting Blocking Sessions in RAC and non-RAC (Enqueue Locks) Environments&#8221; &#8211; BLOCK &#8220;value is always 2 in RAC environments unless there is local conflict&#8221; &#8211; joins ID1 of V$LOCK to DBA_OBJECTS.OBJECT_ID<br />
Metalink Doc ID 102925.1 &#8220;Tracing sessions: waiting on an enqueue&#8221; &#8211; &#8220;For the lock type TM (table lock), column ID1 is the object_id (or the data_object_id) for that table (could be joined with DBA_OBJECTS).&#8221; &#8211; seems to be unclear which column.<br />
Metalink Doc ID 62354.1 &#8220;TX Transaction locks &#8211; Example wait scenarios&#8221; &#8211; avoids the question.<br />
Metalink Doc ID 43724.1 &#8220;VIEW: &#8216;V$LOCKED_OBJECT&#8217; Reference Note&#8221; &#8211; &#8220;This view lists all locks acquired by every transaction on the system.&#8221; &#8211; &#8220;OBJECT_ID &#8211; Object ID being locked&#8221;</p>
<pre>
SQL&gt; DESC DBA_OBJECTS
 Name
 ------------------------
 OWNER
 OBJECT_NAME
 SUBOBJECT_NAME
 OBJECT_ID
 DATA_OBJECT_ID
 OBJECT_TYPE
 CREATED
 LAST_DDL_TIME
 TIMESTAMP
 STATUS
 TEMPORARY
 GENERATED
 SECONDARY

SQL&gt; DESC V$LOCKED_OBJECT
 Name
 ------------------------
 XIDUSN
 XIDSLOT
 XIDSQN
 OBJECT_ID
 SESSION_ID
 ORACLE_USERNAME
 OS_USER_NAME
 PROCESS
 LOCKED_MODE
</pre>
<p>It looks like the only option to join these two views is OBJECT_ID.  Now maybe someone can help explain what kinds of problems that might cause.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Flado</title>
		<link>http://hoopercharles.wordpress.com/2010/06/03/lock-watching-what-is-wrong-with-this-sql-statement/#comment-1347</link>
		<dc:creator><![CDATA[Flado]]></dc:creator>
		<pubDate>Fri, 11 Jun 2010 11:40:16 +0000</pubDate>
		<guid isPermaLink="false">http://hoopercharles.wordpress.com/?p=2529#comment-1347</guid>
		<description><![CDATA[I might be nitpicking here, but shouldn&#039;t &quot;do.object_id&quot; actually be &quot;do.data_object_id&quot;?

Cheers,
Flado]]></description>
		<content:encoded><![CDATA[<p>I might be nitpicking here, but shouldn&#8217;t &#8220;do.object_id&#8221; actually be &#8220;do.data_object_id&#8221;?</p>
<p>Cheers,<br />
Flado</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Charles Hooper</title>
		<link>http://hoopercharles.wordpress.com/2010/06/03/lock-watching-what-is-wrong-with-this-sql-statement/#comment-1323</link>
		<dc:creator><![CDATA[Charles Hooper]]></dc:creator>
		<pubDate>Mon, 07 Jun 2010 12:45:10 +0000</pubDate>
		<guid isPermaLink="false">http://hoopercharles.wordpress.com/?p=2529#comment-1323</guid>
		<description><![CDATA[Timur,

Thank you for performing the test on a RAC configuration.]]></description>
		<content:encoded><![CDATA[<p>Timur,</p>
<p>Thank you for performing the test on a RAC configuration.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Timur Akhmadeev</title>
		<link>http://hoopercharles.wordpress.com/2010/06/03/lock-watching-what-is-wrong-with-this-sql-statement/#comment-1321</link>
		<dc:creator><![CDATA[Timur Akhmadeev]]></dc:creator>
		<pubDate>Mon, 07 Jun 2010 11:23:51 +0000</pubDate>
		<guid isPermaLink="false">http://hoopercharles.wordpress.com/?p=2529#comment-1321</guid>
		<description><![CDATA[&gt;Now the question that I have for you is what happens when one session blocks another session. Do you see one of the BLOCK=2 rows become a BLOCK=1 row?
Yes - in case of sessions are on the same instance. It remains 2 when sessions are located on different nodes.]]></description>
		<content:encoded><![CDATA[<p>&gt;Now the question that I have for you is what happens when one session blocks another session. Do you see one of the BLOCK=2 rows become a BLOCK=1 row?<br />
Yes &#8211; in case of sessions are on the same instance. It remains 2 when sessions are located on different nodes.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Charles Hooper</title>
		<link>http://hoopercharles.wordpress.com/2010/06/03/lock-watching-what-is-wrong-with-this-sql-statement/#comment-1315</link>
		<dc:creator><![CDATA[Charles Hooper]]></dc:creator>
		<pubDate>Mon, 07 Jun 2010 10:20:43 +0000</pubDate>
		<guid isPermaLink="false">http://hoopercharles.wordpress.com/?p=2529#comment-1315</guid>
		<description><![CDATA[Timur,

Excellent.  Now the question that I have for you is what happens when one session blocks another session.  Do you see one of the BLOCK=2 rows become a BLOCK=1 row?  For instance, if you try the test case found in this blog article:
http://hoopercharles.wordpress.com/2010/01/07/deadlock-on-oracle-11g-but-not-on-10g/
What do you see when both sessions 2 and 3 hang?  Do you see something similar to my results that I posted a couple of days ago, further down this page?]]></description>
		<content:encoded><![CDATA[<p>Timur,</p>
<p>Excellent.  Now the question that I have for you is what happens when one session blocks another session.  Do you see one of the BLOCK=2 rows become a BLOCK=1 row?  For instance, if you try the test case found in this blog article:<br />
<a href="http://hoopercharles.wordpress.com/2010/01/07/deadlock-on-oracle-11g-but-not-on-10g/" rel="nofollow">http://hoopercharles.wordpress.com/2010/01/07/deadlock-on-oracle-11g-but-not-on-10g/</a><br />
What do you see when both sessions 2 and 3 hang?  Do you see something similar to my results that I posted a couple of days ago, further down this page?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Timur Akhmadeev</title>
		<link>http://hoopercharles.wordpress.com/2010/06/03/lock-watching-what-is-wrong-with-this-sql-statement/#comment-1314</link>
		<dc:creator><![CDATA[Timur Akhmadeev]]></dc:creator>
		<pubDate>Mon, 07 Jun 2010 07:24:10 +0000</pubDate>
		<guid isPermaLink="false">http://hoopercharles.wordpress.com/?p=2529#comment-1314</guid>
		<description><![CDATA[&gt;a 2 may appear in the BLOCK column in a RAC environment, even though the documentation suggests that only 0 or 1 may appear in that column
AFAIK it is almost always 2 in RAC
[sourcecode lang=&quot;sql&quot;]
SQL&gt; select block, count(*) from v$lock group by block;
 
     BLOCK   COUNT(*)
---------- ----------
         2       2189
         1          1
         0         12
[/sourcecode]]]></description>
		<content:encoded><![CDATA[<p>&gt;a 2 may appear in the BLOCK column in a RAC environment, even though the documentation suggests that only 0 or 1 may appear in that column<br />
AFAIK it is almost always 2 in RAC</p>
<pre class="brush: sql; title: ; notranslate">
SQL&gt; select block, count(*) from v$lock group by block;
 
     BLOCK   COUNT(*)
---------- ----------
         2       2189
         1          1
         0         12
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Charles Hooper</title>
		<link>http://hoopercharles.wordpress.com/2010/06/03/lock-watching-what-is-wrong-with-this-sql-statement/#comment-1299</link>
		<dc:creator><![CDATA[Charles Hooper]]></dc:creator>
		<pubDate>Sat, 05 Jun 2010 02:38:32 +0000</pubDate>
		<guid isPermaLink="false">http://hoopercharles.wordpress.com/?p=2529#comment-1299</guid>
		<description><![CDATA[Another clue, this is from Oracle Database 10.2.0.2 when sessions 2 and 3 lock up while executing the test script for this article:
&lt;pre&gt;
SQL&gt; SELECT /*+ ORDERED */
  2  S.SID, S.USERNAME, S.PROGRAM, S.STATUS, SW.EVENT, SW.WAIT_TIME WT, SW.STATE,
  3  SW.SECONDS_IN_WAIT S_I_W, S.SQL_ID, S.SQL_ADDRESS, S.SQL_HASH_VALUE,
  4  S.SQL_CHILD_NUMBER, S.ROW_WAIT_OBJ# OBJ#, S.ROW_WAIT_FILE# FILE#,
  5  S.ROW_WAIT_BLOCK# BLOCK#, S.ROW_WAIT_ROW# ROW#, SW.P1, SW.P2, SW.P3
  6  FROM
  7  V$SESSION_WAIT SW, V$SESSION S
  8  WHERE
  9  S.USERNAME IS NOT NULL
 10  AND SW.SID=S.SID
 11  AND SW.EVENT NOT LIKE &#039;%SQL*Net%&#039;
 12  AND SW.EVENT NOT IN (&#039;Streams AQ: waiting for messages in the queue&#039;,
 13  &#039;wait for unread message on broadcast channel&#039;);
  
SID USERNAME PROGRAM     STATUS   EVENT                WT STATE   S_I_W SQL_ID        SQL_ADDRESS      SQL_HASH_VALUE SQL_CHILD_NUMBER OBJ# FILE# BLOCK# ROW#         P1     P2 P3
--- -------- ----------- -------- -------------------- -- ------- ----- ------------- ---------------- -------------- ---------------- ---- ----- ------ ---- ---------- ------ --
214 TESTUSER sqlplus.exe ACTIVE   enq: TM - contention  0 WAITING   213 dxbtvfguaa0xq 000007FFA479BDE0     4104455094                0   -1     0      0    0 1414332421 114337  0
217 TESTUSER sqlplus.exe ACTIVE   enq: TM - contention  0 WAITING    78 873s5kmm4fkfa 000007FFA5182400     3863431626                0   -1     0      0    0 1414332418 114337  0
&lt;/pre&gt;

From the above, sessions 2 and 3 are enqueing with a TM type enqueue, with both pointing at whatever is object ID 114337.  V$SESSION.ROW_WAIT_OBJ# shows -1, but we are able to determine the object ID from the value of P2.

This is the second checking SQL statement, executed at the same point in the test case:
&lt;pre&gt;
SQL&gt; SELECT
  2  S.SID, S.USERNAME, S.PROGRAM, S.SQL_ID, S.SQL_ADDRESS, S.SQL_HASH_VALUE,
  3  S.SQL_CHILD_NUMBER CN, S.ROW_WAIT_OBJ#, S.ROW_WAIT_FILE#, S.ROW_WAIT_BLOCK#,
  4  S.ROW_WAIT_ROW#, L.LMODE, L.REQUEST, L.ID1, L.ID2, L.TYPE, L.BLOCK
  5  FROM
  6  V$LOCK L,
  7  V$SESSION S
  8  WHERE
  9  (L.ID1, L.ID2, L.TYPE) IN
 10  (SELECT
 11  ID1, ID2, TYPE
 12  FROM
 13  V$LOCK
 14  WHERE
 15  REQUEST &gt; 0)
 16  AND L.SID=S.SID;
 
SID USERNAME PROGRAM     SQL_ID        SQL_ADDRESS      SQL_HASH_VALUE CN ROW_WAIT_OBJ# ROW_WAIT_FILE# ROW_WAIT_BLOCK# ROW_WAIT_ROW# LMODE REQUEST    ID1 ID2 TY BLOCK
--- -------- ----------- ------------- ---------------- -------------- -- ------------- -------------- --------------- ------------- ----- ------- ------ --- -- -----
211 TESTUSER sqlplus.exe 8sx6uby71yy6x 000007FFA3E7B490     2384427229  0           107              1             810             0     3       0 114337   0 TM     1
214 TESTUSER sqlplus.exe dxbtvfguaa0xq 000007FFA479BDE0     4104455094  0            -1              0               0             0     3       5 114337   0 TM     0
217 TESTUSER sqlplus.exe 873s5kmm4fkfa 000007FFA5182400     3863431626  0            -1              0               0             0     0       2 114337   0 TM     0
&lt;/pre&gt;

The above output shows that session 211 (session 1) is blocking sessions 2 and 3 - we are able to determine that because ID1, ID2, and TYPE all match.

Now, the SQL statement that appears at the start of this blog article:
&lt;pre&gt;
SQL&gt; select s1.username blkg_user, s1.machine blkg_ws, s1.sid blkg_sid,
  2         s2.username wait_user, s2.machine wait_ws, s2.sid wait_sid,
  3         lo.object_id blkd_obj_id, do.owner, do.object_name
  4  from v$lock l1, v$session s1, v$lock l2, v$session s2,
  5       v$locked_object lo, dba_objects do
  6  where s1.sid = l1.sid
  7    and s2.sid = l2.sid
  8    and l1.id1 = l2.id1
  9    and s1.sid = lo.session_id
 10    and lo.object_id = do.object_id
 11    and l1.block = 1
 12    and l2.request &gt; 0
 13  ;
 
BLKG_USER BLKG_WS         BLKG_SID WAIT_USER WAIT_WS         WAIT_SID BLKD_OBJ_ID OWNER    OBJECT_NAME
--------- --------------- -------- --------- --------------- -------- ----------- -------- -----------
TESTUSER  K-MM\AIRFORCE-1      211 TESTUSER  K-MM\AIRFORCE-1      217      114335 TESTUSER T5
TESTUSER  K-MM\AIRFORCE-1      211 TESTUSER  K-MM\AIRFORCE-1      214      114335 TESTUSER T5
TESTUSER  K-MM\AIRFORCE-1      211 TESTUSER  K-MM\AIRFORCE-1      217      114337 TESTUSER T6
TESTUSER  K-MM\AIRFORCE-1      211 TESTUSER  K-MM\AIRFORCE-1      214      114337 TESTUSER T6
&lt;/pre&gt; 

Object ID 114337 appearing in the output is expected - my script that targeted V$SESSION_WAIT showed that object ID also, but why is OBJECT ID 114335 in the list?

Note that the above output could be a bit different with Oracle Database 10.2.0.4, and will be different for Oracle Database 11.1.0.6 or higher.]]></description>
		<content:encoded><![CDATA[<p>Another clue, this is from Oracle Database 10.2.0.2 when sessions 2 and 3 lock up while executing the test script for this article:</p>
<pre>
SQL&gt; SELECT /*+ ORDERED */
  2  S.SID, S.USERNAME, S.PROGRAM, S.STATUS, SW.EVENT, SW.WAIT_TIME WT, SW.STATE,
  3  SW.SECONDS_IN_WAIT S_I_W, S.SQL_ID, S.SQL_ADDRESS, S.SQL_HASH_VALUE,
  4  S.SQL_CHILD_NUMBER, S.ROW_WAIT_OBJ# OBJ#, S.ROW_WAIT_FILE# FILE#,
  5  S.ROW_WAIT_BLOCK# BLOCK#, S.ROW_WAIT_ROW# ROW#, SW.P1, SW.P2, SW.P3
  6  FROM
  7  V$SESSION_WAIT SW, V$SESSION S
  8  WHERE
  9  S.USERNAME IS NOT NULL
 10  AND SW.SID=S.SID
 11  AND SW.EVENT NOT LIKE '%SQL*Net%'
 12  AND SW.EVENT NOT IN ('Streams AQ: waiting for messages in the queue',
 13  'wait for unread message on broadcast channel');
  
SID USERNAME PROGRAM     STATUS   EVENT                WT STATE   S_I_W SQL_ID        SQL_ADDRESS      SQL_HASH_VALUE SQL_CHILD_NUMBER OBJ# FILE# BLOCK# ROW#         P1     P2 P3
--- -------- ----------- -------- -------------------- -- ------- ----- ------------- ---------------- -------------- ---------------- ---- ----- ------ ---- ---------- ------ --
214 TESTUSER sqlplus.exe ACTIVE   enq: TM - contention  0 WAITING   213 dxbtvfguaa0xq 000007FFA479BDE0     4104455094                0   -1     0      0    0 1414332421 114337  0
217 TESTUSER sqlplus.exe ACTIVE   enq: TM - contention  0 WAITING    78 873s5kmm4fkfa 000007FFA5182400     3863431626                0   -1     0      0    0 1414332418 114337  0
</pre>
<p>From the above, sessions 2 and 3 are enqueing with a TM type enqueue, with both pointing at whatever is object ID 114337.  V$SESSION.ROW_WAIT_OBJ# shows -1, but we are able to determine the object ID from the value of P2.</p>
<p>This is the second checking SQL statement, executed at the same point in the test case:</p>
<pre>
SQL&gt; SELECT
  2  S.SID, S.USERNAME, S.PROGRAM, S.SQL_ID, S.SQL_ADDRESS, S.SQL_HASH_VALUE,
  3  S.SQL_CHILD_NUMBER CN, S.ROW_WAIT_OBJ#, S.ROW_WAIT_FILE#, S.ROW_WAIT_BLOCK#,
  4  S.ROW_WAIT_ROW#, L.LMODE, L.REQUEST, L.ID1, L.ID2, L.TYPE, L.BLOCK
  5  FROM
  6  V$LOCK L,
  7  V$SESSION S
  8  WHERE
  9  (L.ID1, L.ID2, L.TYPE) IN
 10  (SELECT
 11  ID1, ID2, TYPE
 12  FROM
 13  V$LOCK
 14  WHERE
 15  REQUEST &gt; 0)
 16  AND L.SID=S.SID;
 
SID USERNAME PROGRAM     SQL_ID        SQL_ADDRESS      SQL_HASH_VALUE CN ROW_WAIT_OBJ# ROW_WAIT_FILE# ROW_WAIT_BLOCK# ROW_WAIT_ROW# LMODE REQUEST    ID1 ID2 TY BLOCK
--- -------- ----------- ------------- ---------------- -------------- -- ------------- -------------- --------------- ------------- ----- ------- ------ --- -- -----
211 TESTUSER sqlplus.exe 8sx6uby71yy6x 000007FFA3E7B490     2384427229  0           107              1             810             0     3       0 114337   0 TM     1
214 TESTUSER sqlplus.exe dxbtvfguaa0xq 000007FFA479BDE0     4104455094  0            -1              0               0             0     3       5 114337   0 TM     0
217 TESTUSER sqlplus.exe 873s5kmm4fkfa 000007FFA5182400     3863431626  0            -1              0               0             0     0       2 114337   0 TM     0
</pre>
<p>The above output shows that session 211 (session 1) is blocking sessions 2 and 3 &#8211; we are able to determine that because ID1, ID2, and TYPE all match.</p>
<p>Now, the SQL statement that appears at the start of this blog article:</p>
<pre>
SQL&gt; select s1.username blkg_user, s1.machine blkg_ws, s1.sid blkg_sid,
  2         s2.username wait_user, s2.machine wait_ws, s2.sid wait_sid,
  3         lo.object_id blkd_obj_id, do.owner, do.object_name
  4  from v$lock l1, v$session s1, v$lock l2, v$session s2,
  5       v$locked_object lo, dba_objects do
  6  where s1.sid = l1.sid
  7    and s2.sid = l2.sid
  8    and l1.id1 = l2.id1
  9    and s1.sid = lo.session_id
 10    and lo.object_id = do.object_id
 11    and l1.block = 1
 12    and l2.request &gt; 0
 13  ;
 
BLKG_USER BLKG_WS         BLKG_SID WAIT_USER WAIT_WS         WAIT_SID BLKD_OBJ_ID OWNER    OBJECT_NAME
--------- --------------- -------- --------- --------------- -------- ----------- -------- -----------
TESTUSER  K-MM\AIRFORCE-1      211 TESTUSER  K-MM\AIRFORCE-1      217      114335 TESTUSER T5
TESTUSER  K-MM\AIRFORCE-1      211 TESTUSER  K-MM\AIRFORCE-1      214      114335 TESTUSER T5
TESTUSER  K-MM\AIRFORCE-1      211 TESTUSER  K-MM\AIRFORCE-1      217      114337 TESTUSER T6
TESTUSER  K-MM\AIRFORCE-1      211 TESTUSER  K-MM\AIRFORCE-1      214      114337 TESTUSER T6
</pre>
<p>Object ID 114337 appearing in the output is expected &#8211; my script that targeted V$SESSION_WAIT showed that object ID also, but why is OBJECT ID 114335 in the list?</p>
<p>Note that the above output could be a bit different with Oracle Database 10.2.0.4, and will be different for Oracle Database 11.1.0.6 or higher.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Charles Hooper</title>
		<link>http://hoopercharles.wordpress.com/2010/06/03/lock-watching-what-is-wrong-with-this-sql-statement/#comment-1293</link>
		<dc:creator><![CDATA[Charles Hooper]]></dc:creator>
		<pubDate>Fri, 04 Jun 2010 20:26:51 +0000</pubDate>
		<guid isPermaLink="false">http://hoopercharles.wordpress.com/?p=2529#comment-1293</guid>
		<description><![CDATA[I think that your answer is getting closer to one of the issues that I thought might happen, and the test case for this article did show a problem that indicated a missing join condition.
 
&lt;pre&gt;
SQL&gt; DESC V$LOCK
 
 Name      Null?    Type
 --------- -------- -----------
 ADDR               RAW(4)
 KADDR              RAW(4)
 SID                NUMBER
 TYPE               VARCHAR2(2)
 ID1                NUMBER
 ID2                NUMBER
 LMODE              NUMBER
 REQUEST            NUMBER
 CTIME              NUMBER
 BLOCK              NUMBER
 
SQL&gt; DESC V$LOCKED_OBJECT
 
 Name             Null?    Type
 ---------------- -------- -----------
 XIDUSN                    NUMBER
 XIDSLOT                   NUMBER
 XIDSQN                    NUMBER
 OBJECT_ID                 NUMBER
 SESSION_ID                NUMBER
 ORACLE_USERNAME           VARCHAR2(30)
 OS_USER_NAME              VARCHAR2(30)
 PROCESS                   VARCHAR2(24)
 LOCKED_MODE               NUMBER
&lt;/pre&gt;

Unfortunately, there is no OBJECT_ID column in V$LOCK.  For some types of enqueue entries that appear in V$LOCK, the OBJECT_ID appears in the ID1 column, but that is not consistent across all enqueue types.]]></description>
		<content:encoded><![CDATA[<p>I think that your answer is getting closer to one of the issues that I thought might happen, and the test case for this article did show a problem that indicated a missing join condition.</p>
<pre>
SQL&gt; DESC V$LOCK
 
 Name      Null?    Type
 --------- -------- -----------
 ADDR               RAW(4)
 KADDR              RAW(4)
 SID                NUMBER
 TYPE               VARCHAR2(2)
 ID1                NUMBER
 ID2                NUMBER
 LMODE              NUMBER
 REQUEST            NUMBER
 CTIME              NUMBER
 BLOCK              NUMBER
 
SQL&gt; DESC V$LOCKED_OBJECT
 
 Name             Null?    Type
 ---------------- -------- -----------
 XIDUSN                    NUMBER
 XIDSLOT                   NUMBER
 XIDSQN                    NUMBER
 OBJECT_ID                 NUMBER
 SESSION_ID                NUMBER
 ORACLE_USERNAME           VARCHAR2(30)
 OS_USER_NAME              VARCHAR2(30)
 PROCESS                   VARCHAR2(24)
 LOCKED_MODE               NUMBER
</pre>
<p>Unfortunately, there is no OBJECT_ID column in V$LOCK.  For some types of enqueue entries that appear in V$LOCK, the OBJECT_ID appears in the ID1 column, but that is not consistent across all enqueue types.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
