In this document
|
1. TX deadlock in exclusive (x) Mode |
|
2. TX deadlock in share (s) Mode |
|
4. single resource deadlock for Tx, TM or IV |
Applies to: Oracle Database-Enterprise Edition-version 10.1.0.2 and later
Information in this document applies to any platform.
Purpose
This note is to provide some common causes and solutions for message "Global enqueue services deadlock detected" reported in Alert Log.
Troubleshooting steps
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 wocould see the following messages in Database Alert Log:
Global enqueue services deadlock detected. More info in file
/U01/diag/rdbms/RAC/Rac1/Trace/racw.ora_3457040.trc.
Or
Global enqueue services deadlock detected. More info in file
/U01/diag/rdbms/RAC/Rac1/Trace/racw.lmd0_30429.trc.
The major difference of deadlock between single instance and Rac is the Sessions involved in a deadlock cocould be from different instances and there cocould 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, there are similar to single instance deadlock.
To understand the basics of deadlock, refer to the following statements:
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:
1. TX deadlock in exclusive (x) modetrace shows:
Global wait-for-graph (WFG) at DDTs [0.170]:
Blocked 0x8aafb0ec
5WQ 2 cvtops X1
TX0x320001. 0x121c97 [99000-0001-00000002] 0
Blocker 0x8aafafec
5WQ 1 cvtops X8
TX0x320001. 0x121c97 [9a000-0001-00000002] 0
Blocked 0x8acb55e4
5WQ 2 cvtops X1
TX0x430003. 0x3843f [9a000-0001-00000002] 0
Blocker 0x8acb54e4
5WQ 1 cvtops X8
TX0x430003. 0x3843f [99000-0001-00000002] 0
These values are:
<Blocked | blocker> <lockp> <CVT | held mode> <res Name> <pid | did | txn_id> <node>
Mode 5 is exclusive lock
Instance # Starts from 0
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:
User session for deadlock lock 0x8aafb0ec:
...
Current SQL:
Update Test Set owner = 'apps' where rownum <2
2. TX deadlock in share (s) modetrace shows:
Global wait-for-graph (WFG) at DDTs [0. B7]:
Blocked 0x2310e8918
3[0x731000e] [0x56268], [
TX[F1000-0001-0000000F] 0
Blocker 0x2310e87c8
3[0x731000e] [0x56268], [
TX] [19f000-0001-00000011] 0
Blocked 0x2310e3c50
3[0x72a0023] [0x530d7], [
TX] [19f000-0001-00000011] 0
Blocker 0x2310e7e80
3[0x72a0023] [0x530d7], [
TX[F1000-0001-0000000F] 0
Mode 3 is shared lock
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 shocould be checked including table and its associated index.
B. If the object involved is an unique key index, the wait cocould 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 shocould be dropped to accommodate concurrent DML. Please refer to document 1496403.1 ORA-60 deadlock due to bitmap index in RAC.
3. tm deadlocktrace shows:
Global wait-for-graph (WFG) at DDTs [0.1]:
Blocked 0x7000003ccbf4798 3 WQ 2 cvtops X1
TM0x1cbde. 0x0 [1004-004d-00000003] 0
Blocker 0x7000003d0bf9ad8 3 WQ 1 cvtops X1 TM 0x1cbde. 0x0 [200a-00ac-00000019] 1
Blocked 0x7000003d0bfcf88 2 WQ 2 cvtops X1 TM 0x1cc77. 0x0 [200a-00ac-00000019] 1
Blocker 0x7000003cc338e88 2 WQ 2 cvtops X1 TM 0x1cc77. 0x0 [2006-0063-00000055] 1
Blocked 0x7000003cc338e88 3 WQ 2 cvtops X1 TM 0x1cc77. 0x0 [2006-0063-00000055] 1
Blocker 0x7000003c879f9c0 3 WQ 1 cvtops X1 TM 0x1cc77. 0x0 [2006-0063-00000020] 1
Blocked 0x7000003c87978a8 2 WQ 2 cvtops X1 TM 0x1cbde. 0x0 [2006-0063-00000020] 1
Blocker 0x7000003ccbf4798 2 WQ 2 cvtops X1 TM 0x1cbde. 0x0 [1004-004d-00000003] 0
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.
4. single resource deadlock for Tx, TM or ivtrace shows:
Single resource deadlock: Blocking enqueue which blocks itself, F 1
Granted global enqueue 0xd078cec0
...
Resname: [0x2001f] [0x1a96c3], [TX]
Or
Resname: [0x00001432] [0x0], [Tm]
Or
Resname: [0xbb7cc5db] [0x82d0d4b5], [IV]
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 wocould consider any DML statement under this transaction as a separate one (commit/rollback won't affect the parent ), and this wowould 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.
5. lb deadlockglobal wait-for-graph (WFG) at DDTs [0.390]:
Blocked 0x3bc3e1b48 5 WQ 2 cvtops x0 [0xd2703c03] [0x545a14a5], [
LB] [7b000-0002-4256c9d] 1
Blocker 0x3bc2efad0 5 WQ 1 cvtops x0 [0xd2703c03] [0x545a14a5], [
LB] [48000-0001-10869fe] 0
Blocked 0x3bc2ed1c0 3 WQ 2 cvtops x0 [0x0000d0160] [0xca28e8cf], [
LB] [48000-0001-10869fe] 0
Blocker 0x3bc2dc648 3 WQ 2 cvtops x0 [0x0000d0160] [0xca28e8cf], [
LB] [34000-0001-0000095e] 0
Blocked 0x3bc2dc648 5 WQ 2 cvtops x0 [0x0000d0160] [0xca28e8cf], [
LB] [34000-0001-0000095e] 0
Blocker 0x3bc2dbbb0 5 WQ 1 cvtops x0 [0x0000d0160] [0xca28e8cf], [
LB] [76000-0002-000074d4] 1
Blocked 0x3bc2ef830 3 WQ 2 cvtops x0 [0xd2703c03] [0x545a14a5], [
LB] [76000-0002-000074d4] 1
Blocker 0x3bc3e1b48 3 WQ 2 cvtops x0 [0xd2703c03] [0x545a14a5], [
LB] [7b000-0002-4256c9d] 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.
6. Known issues
For other deadlock type or known issues related to dead lock, refer to document 554567.1 Summary of bugs which cocould cause deadlock in RAC Environment
7. Further Diagnosis
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 dumpOnlyIf the information in Trace files are insufficient:
Alter system set events '60 trace name systemstate level 258 ';
It will cause a systemstate dump to be generated whenever a deadlock is reported. If there are constant deadlocks, it cocould cause a lot of Trace files being generated, monitor the system carefully.
To turn off the trace:
Alter system set events '60 trace name context off ';
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)