0% found this document useful (0 votes)
101 views4 pages

Deadlock Blockings

1) An alert was generated due to a deadlock detected in the database. 2) The alert log was checked which contained a deadlock trace that was attached to a case and assigned to the application support team as it was related to the application layer. 3) Blocking sessions were identified from v$session and v$lock views which showed one session blocking another. The blocking session was killed to resolve the deadlock.

Uploaded by

ram
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
101 views4 pages

Deadlock Blockings

1) An alert was generated due to a deadlock detected in the database. 2) The alert log was checked which contained a deadlock trace that was attached to a case and assigned to the application support team as it was related to the application layer. 3) Blocking sessions were identified from v$session and v$lock views which showed one session blocking another. The blocking session was killed to resolve the deadlock.

Uploaded by

ram
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 4

dead locks:-

==========
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.

ORA-00060: Deadlock detected. See Note 60.1 at My Oracle Support for


Troubleshooting ORA-60 Errors. More info in file
/u01/app/oracle/diag/rdbms/arun/ARUN/trace/ARUN_ora_28936.trc.
Thu Nov 08 15:06:59 2018

SQL> select sid,serial#,username,status from v$session where username not


in('SYS','SYSTEM');

SID SERIAL# USERNAME STATUS


---------- ---------- ------------------------------ --------
60 58534 SCOTT INACTIVE
76 21128 U1 ACTIVE
SQL> select 'alter system kill session '''||sid||','||serial#||''';' from
v$session where status='INACTIVE' and username not in ('SYS','SYSTEM');

'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
/

BLOCKING_SESSION SID SERIAL# SECONDS_IN_WAIT SQL_ID USERNAME


---------------- ---------- ---------- --------------- -------------
------------------------------
60 76 21128 49 8c8ua6qkc0tkd U1
or

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

SQL> select sid,serial#,username,status from v$session where sid=62;

SID SERIAL# USERNAME STATUS


---------- ---------- ------------------------------ --------
60 62741 SCOTT INACTIVE

SQL> select sid,serial#,username,status from v$session where sid=46;

SID SERIAL# USERNAME STATUS


---------- ---------- ------------------------------ --------
76 17108 U1 ACTIVE

select sid,serial# from V$session where sid in (698);


select sid,serial#,username from V$session where sid in (60,76);
SID SERIAL# USERNAME
---------- ---------- ------------------------------
60 58534 SCOTT
SQL> select sid,serial#,username,status from V$session where sid in(60,76);

SID SERIAL# USERNAME STATUS


---------- ---------- ------------------------------ --------
60 17108 U1 ACTIVE
76 62741 SCOTT INACTIVE

alter system kill session '698,19999' immediate;

select 'alter system kill session '''||sid||','||serial#||''';' from v$session


where sql_id='1w6w4gagv86rd';

select 'alter system kill session '''||sid||','||serial#||''';' from v$session


where sid=60;
SQL> select 'alter system kill session '''||sid||','||serial#||''';' from v$session
where sid=60;

'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"

then get the pid using sid:-


==========================
col sid format 999999
col username format a20
col osuser format a15
select a.sid, a.serial#,a.username, a.osuser, b.spid
from v$session a, v$process b
where a.paddr= b.addr
and a.sid='&sid'
order by a.sid;

new 4: and a.sid='60'

SID SERIAL# USERNAME OSUSER SPID


------- ---------- -------------------- --------------- ------------------------
60 58534 SCOTT oracle 4271

[oracle@server1 ~]$ ps -ef | grep 4271


oracle 4271 4269 0 16:42 ? 00:00:00 oracleprod1
(DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))
oracle 4545 3809 0 16:53 pts/1 00:00:00 grep 4271

col sid format 999999


col username format a20
col osuser format a15
select b.spid,a.sid, a.serial#,a.username, a.osuser
from v$session a, v$process b
where a.paddr= b.addr
and b.spid='&spid'

new 4: and b.spid='4271'

oSPID SID SERIAL# USERNAME OSUSER


------------------------ ------- ---------- -------------------- ---------------
4271 60 58534 SCOTT oracle

$ kill -9 4271

wait for few seconds it will clear the session.

SQL> select 17108/60/24 from dual;

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;

BLOCKING_SESSION SID SERIAL# STATUS USERNAME WAIT_CLASS


SECONDS_IN_WAIT SQL_ID
---------------- ------- ---------- -------- -------------------- ---------------
--------------- -------------
60 76 21128 ACTIVE U1 Application
3449 8c8ua6qkc0tkd

You might also like