Teaches you how to check for Oracle deadlocks, to unlock the deadlock

Source: Internet
Author: User
Tags dba

Oracle deadlock problem has been bothering us, here is to teach you an Oracle deadlock check method, if you have encountered the problem of Oracle deadlock, may wish to see ...

Oracle deadlock problem has been bothering us, let's teach you an Oracle deadlock check method, if you have encountered the problem of Oracle deadlock, may wish to see.

First, the phenomenon of database deadlock

During the execution of the program, click OK or save button, the program is not responding, there is no error.

Second, the principle of Oracle deadlock

When the database of a table of a column to do the update or delete operations, after the completion of the statement is not committed, and another for this column of data do update operation of the statement will be in the waiting state, the phenomenon is that this statement has been executing, but has not executed successfully, there is no error.

Third, the location method of Oracle Deadlock

By checking the database tables, it is possible to check which statement is deadlocked and which is the machine that generated the deadlock.

1) Execute the following statement with the DBA user

Here is the code snippet:

Select  from where inch (Select from V$locked_object)

If there is a result of the output, then there is a deadlock, and the machine that can see the deadlock is which one. Field Description:

Username: The database user used by the deadlock statement;

Lockwait: The state of the deadlock if there is a content representation being deadlocked.

Status: State, active indicates deadlock

Machine: The device where the deadlock statement resides.

Program: The main application that generated the deadlock statement.

2) You can view the deadlock statement by executing the following statement with the DBA user.

Select  from where inch (Selectfromwhere in (Select from v$ Locked_object))

1. Kill the deadlock process:

Alter system kill session ' sid,serial# '; (where sid=l.session_id)

2. If it is not resolved: (Linux)

Select Pro.spid from v$session ses, v$process Pro where ses.sid=xx and ses.paddr=pro.addr;

Where SID is replaced with a dead-lock SID:

Exit
Ps-ef|grep spid

Where SPID is the process number of this process, kill the Oracle process.

Teaches you how to check for Oracle deadlocks, to unlock the deadlock

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.