Resolve locking situation

A blocking lock is when a resource is locked from one session, and another session needs to acquire a new non compatible lock on the same resource. Find the locking resources with the following statement:

SELECT a.sid||decode(request,0,'(holder)','(waiter)'||':blocked by:'||blocking_session) sess_id ,
lmode,
request,
a.type,
c.object_name,
decode(row_wait_obj#,-1,'Holder of Lock !!!',
dbms_rowid.rowid_create(1,row_wait_obj#,row_wait_file#,row_wait_block#,row_wait_row#)) row_id,
nvl(SQL_FULLTEXT,'Holder of Lock !!!')
FROM V$LOCK A, V$LOCKED_OBJECT B, ALL_OBJECTS C, V$SESSION D, V$SQL E
WHERE (id1, id2, a.type) in (select id1, id2, type from v$lock where request>0)
AND a.sid = b.session_id
AND b.object_id = c.object_id
AND d.sid = a.sid
AND d.sql_hash_value = e.hash_value(+);

Then you can find the row with the following:

select * from <object name> where rowid = <rowid>

Leave a Reply

Your email address will not be published. Required fields are marked *