Specific solution for killing deadlocks in Oracle Processes

Source: Internet
Author: User

The problem we often encounter in actual operations is that in Oracle, the actual status has been set to "killed ", however, the process locks related system resources for a long time, but does not release it. We recommend a better way than restarting the database, that is, to forcibly kill those Oracle processes at the operating system level.

1. The following statement is used to query which objects are locked:

 
 
  1. col object_name for a30  
  2. col machine for a20  
  3. select object_name,machine,s.sid,s.serial#   
  4. from v$locked_object l,dba_objects o ,v$session s  
  5. where l.object_id = o.object_id and l.session_id=s.sid;  

2. The following statement is used to kill a process:

 
 
  1. alter system kill session '42,21993';  

(24,111 is the sid, serial # found above #)

You can use the following query to obtain statements similar to the preceding one in batches:

 
 
  1. select 'alter system kill session ''' ||s.sid||','||s.serial#||'''; '  
  2. from v$locked_object l,dba_objects o ,v$session s  
  3. where l.object_id = o.object_id and l.session_id=s.sid;  

3. if the Oracle process state is set to "killed" after a process is killed by using the preceding command, but the locked resources are not released for a long time, the corresponding process thread can be killed at the OS level), and the process thread is obtained first) Number:

 
 
  1. select spid, osuser, s.program   
  2. from v$session s,v$process p  
  3. where s.paddr=p.addr and s.sid=#sid;  

# Sid is the sid above)

4. Kill the corresponding process thread in the operating system ):

1) in Linux, run the command as root:

Kill-9 1234512345 is the spid obtained in step 1)

2) use orakill to kill a thread in windows. orakill is an executable Command provided by oracle. The syntax is orakill sid thread.

Where:

Sid: indicates the Instance name of the Oracle process to be killed.

Thread: the ID of the thread to be killed, that is, the spid obtained in step 1.

Example:

 
 
  1. c:>orakill orcl 12345  

You can write a stored procedure for Combined Query to automatically perform the preceding four steps to conveniently kill all Oracle processes that do not automatically release resources. However, this is generally not recommended, after all, using the root user to kill the process in the system is inherently risky!

Article by: http://database.csdn.net/c_oracle/tag/2

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.