标签:style http color os io strong ar for art
In this Document
Purpose |
Troubleshooting Steps |
1. TX deadlock in Exclusive(X) mode |
2. TX deadlock in Share(S) mode |
3. TM deadlock |
4. Single resource deadlock for TX , TM or IV |
5. LB deadlock |
6. Known Issues |
7. Further Diagnosis |
References |
This note is to provide some common causes and solutions for message "Global Enqueue Services Deadlock detected" reported in alert log.
In single instance environment, when a deadlock happens, it often reports ORA-60, see Document 15476.1 FAQ: Detecting and Resolving Locking Conflicts and Ora-00060 errors. In a Real Application Cluster (RAC) environment, instead of ORA-60, one would see the following messages in database alert log:
The major difference of deadlock between single instance and RAC is the sessions involved in a deadlock could be from different instances and there could be more than 2 sessions involved. When Global Enqueue Service Deadlock is reported, the session which initiates the deadlock checking will be terminated to resolve the deadlock. There are different deadlock types in RAC environment, many are similar to single instance deadlock.
To understand the basics of deadlock, refer to the following documents:
Document 62365.1 What to do with "ORA-60 Deadlock Detected" Errors
Document 62354.1 TX Transaction locks - Example wait scenarios
GV$GES_ENQUEUE and GV$GES_BLOCKING_ENQUEUE can be used to query Global Enqueue Service(GES) lock, they may not necessary involve in a deadlock. Deadlock related information (session, SQL statement etc) will be printed in lmd0 or foreground trace file.
With Bug 6343023 fixed in 10.2.0.5, 11.1.0.7 and all 11.2, the offending SQL statements from
involved sessions will be written in the trace. For earlier version or if there is no SQL statements in the trace, apply patch 6343023 or
use step 6 to gather system state dump.
Here are some common deadlock types:
Above deadlock means two sessions involved in TX-0x320001-0x121c97 and TX-0x430003-0x3843f forms a deadlock, both sessions are from instance 1.
This is a typical application transaction TX enqueue lock, usually caused by SQL commit sequence and high concurrency. To avoid such deadlock, application code and logic need to be modified.
The application and SQL involved in the deadlock can be found in lmd0 or foreground trace (check all instances). Search for: "user session for deadlock lock" section to find out the SQL involved in the deadlock. For example:
The causes for TX deadlock in S mode wait can be:
a. ITL contention, eg: INITRANS setting for the object is too small, it can not handle the number of concurrent transactions.
The solution is to increase INITRANS setting for the object involved in the deadlock using "alter table" or "alter index" command
The SQL involved in the deadlock can be found in lmd0 or client trace. The object involved in the SQL should be checked including table and its associated index.
b. If the object involved is an unique key index, the wait could be caused by uniqueness validation. Application needs to be checked to avoid unique key violation.
c. If the object involved has a bitmap index, then the bitmap index should be dropped to accommodate concurrent DML. Please refer to Document
1496403.1 ORA-60 DEADLOCK DUE TO BITMAP INDEX IN RAC.
The object involved here are 0x1cdbe and 0x1cc77, convert the hex number to decimal, they are the object_id for the tables involved in above deadlock
The deadlock is usually caused by missing index for foreign key constraint, refer to Document 473124.1 - "Frequent GES: Potential Blocker (Pid=nnnn) On Resource TM-<id1>-<id2>" for more information. Check dba_constraints and dba_index to verify if foreign key index is missing. Also refer to Document 1019527.6 Script to Check for Foreign Key Locking Issues for a Specific User which will generate a report for all problem objects.
The solution is to create index for every foreign key constraint.
a. For single resource deadlock on TX enqueue, often it is caused by using autonomous transaction in stored procedure or PL/SQL. It is a known issue that the use of autonomous transactions is vulnerable to deadlocks. Please check out Oracle? Database Concepts Overview
of Autonomous Transactions for detail explanation. Since AUTONOMOUS transaction has been used in the stored procedure, the system would consider any DML statement under this transaction as a separate one (commit/rollback won‘t affect the parent), and this
would cause conflict if the same row is involved in the parent transaction (INSERT, UPDATE or DELETE), and hence deadlock is reported rightly. Usually the SQL involved in the deadlock is called from a stored procedure or PL/SQL with the following line:
PRAGMA AUTONOMOUS_TRANSACTION;
To avoid such deadlock, please remove the autonomous transaction in the application code.
b. If there is no autonomous_transaction involved, please check out Document 6145177.8, it can also be caused by Bug 6145177 - Single resource deadlock with a zero DID
c. For single resource deadlock on TM enqueue, missing foreign key index is often the cause, please check case 3 for the solution.
d. For single resource deadlock type IV (Instance Validation), refer to Document 973178.1, as mentioned in Bug 8843816, this message can be ignored. Bug 8843816has been fixed in 11.1.
LB lock type refers to library cache lock. This type of deadlock is usually caused by a bug.
For example: Bug 6475688 Concurrent rewrite and on-commit refresh can deadlock (library cache
pin <--> lock) Document 6475688.8
The bug has been fixed in 11.1.0.7 and 11.2. Please apply patch accordingly.
For other deadlock type or known issues related to dead lock, refer to Document 554567.1 Summary Of Bugs Which Could Cause Deadlock In RAC Environment
Please collect the following information for further diagnosis:
a. alert log lmd0, and trace mentioned in the alert log from all instances.
b. set the following event to collect systemstate dump ONLY if the information in trace files are insufficient:
It will cause a systemstate dump to be generated whenever a deadlock is reported. If there are constant deadlocks, it could cause a lot of trace files being generated, monitor the system carefully.
To turn off the trace:
c. one can also refer to Document 1464909.1 Identify sql statements involved in Deadlock via Logminer to gather SQL information.
Troubleshooting "Global Enqueue Services Deadlock detected" (Doc ID 1443482.1)
标签:style http color os io strong ar for art
原文地址:http://blog.csdn.net/ora_unix/article/details/39027037