{code}
We have the dblink pm from DB2 to DB1
In DB1:
SQL> create table test02049 as select * from user_objects where rownum<3;
Table created.
SQL> select object_name from test02049;
OBJECT_NAME
-----------------------------------------------------------------------------------
ACCOUNT
ACTIVITYCODEHIERARCHY
SQL>
In DB2:
SQL> select object_name from test02049@pm;
OBJECT_NAME
--------------------------------------------------------------------------------------
ACCOUNT
ACTIVITYCODEHIERARCHY
SQL> -- session one
SQL> update test02049@pm set object_name ='new_obj1' where object_name ='ACCOUNT';
1 row updated.
SQL>
We did not make the commit nor rollback
open second session on DB2
SQL> -- session two
SQL> update test02049@pm set object_name ='new_obj2' where object_name ='ACCOUNT';
update test02049@pm set object_name ='new_obj2' where object_name ='ACCOUNT'
*
ERROR at line 1:
ORA-02049: timeout: distributed transaction waiting for lock
ORA-02063: preceding line from PM
Before the second session got time out.
In DB1:
SQL> @vlockb
USERNAME SID SERIAL# TYPE CTIME HELD REQ ID1 ID2
--------------- ----- --------- ---- --------- ---------- ---------- -------- --------
PRIVUSER 2836 3669 TX 21 Exclusive None 917504 1325382
PRIVUSER 2881 53329 TX 18 None Exclusive 917504 1325382
-- we have the blocker 2836, and the requester 2881
SQL> l
1 SELECT SN.Username, M.Sid, SN.SERIAL#, M.Type, m.ctime,
2 DECODE(M.Lmode, 0, 'None', 1, 'Null', 2, 'Row Share', 3, 'Row
3 Excl.', 4, 'Share', 5, 'S/Row Excl.', 6, 'Exclusive', LTRIM(TO_CHAR(Lmode,'990'))) Lmode,
4 DECODE(M.Request, 0, 'None', 1, 'Null', 2, 'Row Share', 3, 'Row Excl.', 4, 'Share', 5, 'S/Row E
5 LTRIM(TO_CHAR(M.Request, '990'))) Request,
6 M.Id1, M.Id2
7 FROM V$SESSION SN
8 , V$LOCK M
9 WHERE
10 (SN.Sid = M.Sid and M.Request ! = 0)
11 or (SN.Sid = M.Sid and M.Request = 0 and Lmode != 4 and (id1, id2)
12 in (select S.Id1, S.Id2 from V$LOCK S where Request != 0 and S.Id1
13 = M.Id1 and S.Id2 = M.Id2) )
14* order by Id1, Id2, M.Request
we want to check out the sql by the blocker:
SQL> @showsql
Enter value for sid_or_null: 2836
old 6: and sid = NVL('&sid_or_null',sid)
new 6: and sid = NVL('2836',sid)
no rows selected
-- We found none.
Then check on the requester:
SQL> /
Enter value for sid_or_null: 2881
old 6: and sid = NVL('&sid_or_null',sid)
new 6: and sid = NVL('2881',sid)
USERNAME SID SQL_TEXT
--------------- ------- ------------------------------------------------------------
PRIVUSER 2881 UPDATE "TEST02049" "A1" SET "OBJECT_NAME" = :"SYS_B_0" WHERE
"A1"."OBJECT_NAME"=:"SYS_B_1"
SQL>
SQL> l
1 select username, sid, sql_text
2 from
3 v$sql sql,
4 v$session sess
5 where sql.address = sess.sql_address
6* and sid = NVL('&sid_or_null',sid)
SQL>
why we did not see the sql from the blocker?
{code}
March 25, 2013 - 9:39 am UTC
2836 isn't executing any SQL, it *has* executed sql, but it isn't currently executing any.
and even if it were executing sql - that wouldn't tell you "this is the sql you are looking for" - it would be some arbitrary bit of sql that session decided to be executing at that moment in time. it wouldn't be the blocking sql (it would be HIGHLY unusual for it to be the blocking sql, that would imply the block sql runs for a really really long time to still be around).
Heck, the sql that "blocked" you might not even be in the shared pool anymore.