The ultimate processing method of Oracle query deadlock and unlocking _oracle

Source: Internet
Author: User

Some Oracle processes are killed, the state is set to "killed", but the locked resources are not released for a long time, sometimes there is no way, had to restart the database. Now provides a way to solve this problem, which cannot be killed in Oracle, and then killed at OS level.

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

Copy Code code as follows:
Select object_name,machine,s.sid,s.serial#
From V$locked_object l,dba_objects O, v$session s
where l.object_id = o.object_id and l.session_id=s.sid;

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

Copy Code code as follows:
Alter system kill session ' 24,111 ';

(24,111 of which are the above query sid,serial#)
The above two steps can be performed through Oracle's management console.

3. If you use the above command to kill a process, the process state is set to "killed", but the locked resource is not released for a long time, then you can kill the corresponding process (thread) at the OS level, first execute the following statement to obtain the process (thread) Number:

Copy Code code as follows:
Select spid, Osuser, S.program
From V$session s,v$process p
where S.paddr=p.addr and s.sid=24

(24 is the SID above)

4. Kill this process (thread) on the OS:

1 on UNIX, execute the command with root:
#kill-9 12345 (that is, the SPID in step 3rd)

2 to kill a thread with Orakill in Windows (Unix also applies), Orakill is an executable command provided by Oracle, syntax:
Orakill SID Thread

which
Sid: Represents the instance name of the process to kill
Thread: Is the number of threads to kill, that is, the 3rd step of the SPID query.
Example: C:>orakill ORCL 12345

Summary: Oracle sessions are locked often. But sometimes alter system kill session ' sid,serial# '; Can only be done by killing the corresponding process on the OS.

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.