Deadlock Blockings
Deadlock Blockings
==========
1) IF any dead lock in the database . we will get alert.
2) login to the server .open alert log
3) check for dead lock trace in alert.
4) copy to local desktop using winscp/ftp and attach that trace to case/mail and
assign the case to app/support team, as this dead lock issue is realted to app
layer.
'ALTERSYSTEMKILLSESSION'''||SID||','||SERIAL#||''';'
-----------------------------------------------------------------------------------
---------------------------
alter system kill session '60,21128';
blocking session:-
================
SELECT
s.blocking_session,
s.sid,
s.serial#,
s.seconds_in_wait,
s.sql_id,
s.username
FROM
v$session s
WHERE
blocking_session IS NOT NULL
/
SELECT
l1.sid || ' is blocking ' || l2.sid blocking_sessions
FROM
v$lock l1, v$lock l2
WHERE
l1.block = 1 AND
l2.request > 0 AND
l1.id1 = l2.id1 AND
l1.id2 = l2.id2
/
BLOCKING_SESSIONS
-----------------------------------------------------------------------------------
----------
60 is blocking 76
'ALTERSYSTEMKILLSESSION'''||SID||','||SERIAL#||''';'
-----------------------------------------------------------------------------------
---------------------------
alter system kill session '60,58534';
sometime even after killing session in the db end still it will block the session,
if you check the status it will show like "KILLED"
$ kill -9 4271
17108/60/24
-----------
11.8805556
===========
SQL> SELECT substr(DECODE(request,0,'Holder: ','Waiter: ')||sid,1,12) sess,
id1, id2, lmode, request, type, inst_id
FROM GV$LOCK
WHERE (id1, id2, type) IN
(SELECT id1, id2, type FROM GV$LOCK WHERE request>0)
ORDER BY id1, request;
2 3 4 5 6
SESS ID1 ID2 LMODE REQUEST TY INST_ID
------------ ---------- ---------- ---------- ---------- -- ----------
Holder: 60 131084 1666 6 0 TX 1
Waiter: 76 131084 1666 0 6 TX 1
SQL> SELECT 'Instance '||s1.INST_ID||' '|| s1.username || '@' || s1.machine
|| ' ( SID=' || s1.sid || ','|| s1.serial#||s1.status|| ' ) is blocking '
|| s2.username || '@' || s2.machine || ' ( SID=' || s2.sid || ' ) ' ||s2.sql_id
FROM gv$lock l1, gv$session s1, gv$lock l2, gv$session s2
WHERE s1.sid=l1.sid AND
s1.inst_id=l1.inst_id AND
s2.sid=l2.sid AND
s2.inst_id=l2.inst_id AND
l1.BLOCK=1 AND
l2.request > 0 AND
l1.id1 = l2.id1 AND
l2.id2 = l2.id2 ;
'INSTANCE'||S1.INST_ID||''||S1.USERNAME||'@'||S1.MACHINE||'(SID='||S1.SID||','||
--------------------------------------------------------------------------------
Instance 1 SCOTT@server1 ( SID=60,58534INACTIVE ) is blocking U1@server1 ( SID
=76 ) 8c8ua6qkc0tkd
SQL> select
blocking_session,
sid,
serial#,status,username,
wait_class,
seconds_in_wait,sql_id
from
v$session
where
blocking_session is not NULL
order by
blocking_session;