oracle deadlock Troubleshooting

This is my project before the group inside, there is a functional module to write a very complex sql stored procedure, each doing business all over the store to call processing logic.

When more than one person to do business call the stored procedure when the page has been unable to respond to stuck where, behind consulted professional dba troubleshoot the problem, is a part of the stored procedure inside the insert, update operation led to deadlock.

Now talk about steps to troubleshoot a deadlock summarized as follows:

1、查行锁:
column event format a30
column sess format a20
set linesize 150
break on id1 skip 1
select decode(request,0,'Holder:',' Waiter:') || s.inst_id || ':' || s.sid||','|| s.serial# sess,
id1, id2, lmode, request, l.type, ctime, s.sql_id, s.event,s.last_call_et
from gv$lock l, gv$session s
where (id1, id2, l.type) in
(select id1, id2, type from gv$lock where request>0)
and l.sid=s.sid
and l.inst_id=s.inst_id
order by id1, ctime desc, request;

2, through the check out line lock bits stored procedure which is caused by a deadlock which sql:

Resulting in the lock table sqlid:
SELECT SQL_TEXT from GV = $ sql SQL_ID WHERE '9g5813my4anbt'; sql statement that is specific check

At the table for the deadlock related by dba permission to view:

* Lock the FROM v $ the SELECT;
the SELECT * the FROM v $ SQLAREA;
the SELECT * the FROM v $ the session;
the SELECT * the FROM v $ Process;
the SELECT * the FROM v $ locked_object;
the SELECT * the FROM all_objects;
the SELECT * the FROM v $ session_wait;
- View table locked
SELECT b.owner, b.object_name, a.session_id, a.locked_mode locked_object from V $ a, B WHERE b.object_id dba_objects = a.object_id;
- Check that the user that the process according to deadlock
select b .username, b.sid, b.serial #, LOGON_TIME from v $ locked_object a, v $ a.session_id the session the WHERE b = b.sid the Order by b.logon_time;
- see attached process
SELECT sid, serial #, username , the FROM v $ OSUSER the session;
. --3 found locked tables sid, serial #, os_user_name, machine_name , terminal, lock type, mode
S.sid the SELECT, s.serial #, s.username, s.schemaname, s.osuser, s.process, s.machine,
s.terminal, s.logon_time, l.type
the FROM v $ S the session, v $ Lock L
the WHERE s.sid = l.sid
the aND iS s.username the NOT NULL
the ORDER BY sid;
this statement will look to lock the database of all the DML statements generated, can also be found,
any DML statements actually had two locks, a table lock is a row lock.
- kill the process sid, serial #

4, the final solution is going to optimize the storage process, or from a business trip optimization before they get resolved, and we had a few tens of millions of large tables of data to do a table partitioning process, different year by year the data falls

Different data files which, I hope that through real problems encountered and solutions of technical help to everyone!

Guess you like

Origin www.cnblogs.com/cx-20190810/p/11331230.html