You are on page 1of 2

oracle - How to troubleshoot enq: TX - row lock contention? - Databa...

1 de 2

http://dba.stackexchange.com/questions/18569/how-to-troubleshoot-en...

How to troubleshoot enq: TX - row lock contention?

I have the following situation.


I have RAC. On both nodes there are the locks.

On the First Node


SID EVENT
USERNAME
BLOCKING_SESSION
OBJECT_NAME LOCKWAIT
SQL_ID
STATUS
1
102 enq: TX - row lock contention
MYUSER
155
TABLE1V
0000000810EFA958
5f4bzdg49fdxq
ACTIVE
2
111 enq: TX - row lock contention
MYUSER
155
TABLE1V
0000000810EFAC98
5f4bzdg49fdxq
ACTIVE

ROW_WAIT_OBJ#
136972
136972

Blocking session info


SID EVENT
USERNAME
SQL_ID
STATUS
1
155 SQL*Net message from client MYUSER
4hw85z8absbjc
INACTIVE

ROW_WAIT_OBJ#

OBJECT_NAME LOCKWAIT

136971

MyTABLEIMAGES_IDPK

On the Second Node


SID EVENT
USERNAME
BLOCKING_SESSION
OBJECT_NAME
LOCKWAIT
SQL_ID
STATUS
1
65 enq: TX - row lock contention
MYUSER
155
FactTABLE1V
0000000810EF9B58 1mznc2z75ksdx
ACTIVE
2
111 enq: TX - row lock contention
MYUSER
155
TABLE1V
0000000810EF9818 5f4bzdg49fdxq
ACTIVE

ROW_WAIT_OBJ#
137033
136972

Blocking session info


SID EVENT
USERNAME
STATUS
1
155 SQL*Net message from client MYUSER
INACTIVE

ROW_WAIT_OBJ#

OBJECT_NAME

127176

MYTableLOG

SQL_ID

Additional Info : Blocking session SQL_TEXT


create or replace procedure ACTIONProcedureDELETE
(
p_ID NUMBER
)
is
cursor oldval is select r.id,r.sessionstatus
from MyTABLEIMAGES r where r.idparent=p_ID;
begin
update

actionmyTableblock r

set r.status='False' where

ID=p_ID;

for oldvalItem in oldval loop


if oldvalItem.Sessionstatus='True' then
update MyTABLEIMAGES r set r.sessionstatus='False' where r.id=oldvalItem.Id;
else
update MyTABLEIMAGES r set r.sessionstatus='True' where r.id=oldvalItem.Id;
end if;
end loop;
end ACTIONProcedureDELETE;

How do I troubleshoot this ?


As you can see blocking session is INACTIVE but still locking.
If I

select v$sql_bind_capture

there is no value for

VALUE_STRING

for blocking session

sql_id

From where to start?


I can guess that there is missing commit/rollback but application developer says "I have everything ok, I have written commit where
it is necessary"
Please help.
oracle

row-lock

wait-types

12/10/2015 10:48

oracle - How to troubleshoot enq: TX - row lock contention? - Databa...

2 de 2

http://dba.stackexchange.com/questions/18569/how-to-troubleshoot-en...

Please help.
oracle

row-lock

wait-types

edited Sep 28 '12 at 18:08

asked May 30 '12 at 10:05

RolandoMySQLDBA

kupa

88.6k

643

12

99

216

19

39

You've got the sql_id for both. Look in v$sql Phil May 30 '12 at 12:16
@Phil I have sql_id for both but still don't know the exact blocking statement because is contains bind
variables. That are not captured in v$sql_bind_capture.I have added some info in "Additional Info" section in
my post above, please see. kupa May 30 '12 at 16:08

2 Answers

You can avoid row lock contention by making sure that the row is available for update
beforehand with a SELECT FOR UPDATE and either WAIT X or NOWAIT , e.g:
create or replace procedure ACTIONProcedureDELETE (p_ID NUMBER)
is
cursor oldval is select r.id,r.sessionstatus
from MyTABLEIMAGES r where r.idparent=p_ID FOR UPDATE NOWAIT;
l_id NUMBER;
begin
select id into l_id from actionmyTableblock where ID=p_ID
FOR UPDATE of status NOWAIT;
update

actionmyTableblock r

set r.status='False' where

ID=p_ID;

for oldvalItem in oldval loop


if oldvalItem.Sessionstatus='True' then
update MyTABLEIMAGES r set r.sessionstatus='False' where r.id=oldvalItem.Id;
else
update MyTABLEIMAGES r set r.sessionstatus='True' where r.id=oldvalItem.Id;
end if;
end loop;
end ACTIONProcedureDELETE;

If the row is locked, you will receive an ORA-00054 which is in most cases preferable to
indefinite waiting.
answered May 31 '12 at 12:57
Vincent Malgrat
3,574

Query

v$transaction

15

on each node to see uncommitted sessions:

SELECT t.start_time, s.sid, s.serial#, s.username, s.status,s.schemaname, s.osuser


, s.process, s.machine, s.terminal, s.program, s.module
, to_char(s.logon_time,'DD/MON/YY HH24:MI:SS') logon_time
FROM v$transaction t, v$session s
WHERE s.saddr = t.ses_addr
ORDER BY start_time;

12/10/2015 10:48