死鎖分析
一個死鎖的分析!
先看報錯的資訊!
*** 2008-05-05 10:24:51.933
*** SESSION ID:(9.14897) 2008-05-05 10:24:51.924
DEADLOCK DETECTED
Current SQL statement for this session:
DELETE FROM ZZRK121R WHERE (ZZRK121R.出租屋編號 IS NOT NULL) AND (ZZRK121R.F00 = '37070500020110')
The following deadlock is not an ORACLE error. It is a
deadlock due to user error in the design of an application
or from issuing incorrect ad-hoc SQL. The following
information may aid in determining the deadlock:
Deadlock graph:
---------Blocker(s)-------- ---------Waiter(s)---------
Resource Name process session holds waits process session holds waits
TM-0000c01b-00000000 16 9 SX SSX 13 57 SX SSX
TM-0000c01b-00000000 13 57 SX SSX 16 9 SX SSX
session 9: DID 0001-0010-00000002 session 57: DID 0001-000D-00000002
session 57: DID 0001-000D-00000002 session 9: DID 0001-0010-00000002
Rows waited on:
Session 57: obj - rowid = 00011BD3 - AAAAAAAALAABKlsAAA
(dictionary objn - 72659, file - 11, block - 305516, slot - 0)
Session 9: obj - rowid = 00011A66 - AAAAAAAARAAAeu8AAA
(dictionary objn - 72294, file - 17, block - 125884, slot - 0)
Information on the OTHER waiting sessions:
Session 57:
pid=13 serial=12588 audsid=1054039 user: 63/MISDORACLE
O/S info: user: SYSTEM, term: unknown, ospid: , machine: zhcxwas1
program: JDBC Thin Client
Current SQL Statement:
DELETE FROM ZZRK121R WHERE ZZRK121R.F00 = '37078500640103'
End of information on OTHER waiting sessions.
很明顯發生了死鎖!
關於死鎖的的SQL語句很明顯!
DELETE FROM ZZRK121R WHERE (ZZRK121R.出租屋編號 IS NOT NULL) AND (ZZRK121R.F00 = '37070500020110')
下面執行這條語句發生的語句鎖資訊
select v$lock.sid,
decode(v$lock.type,
'MR', 'Media Recovery',
'RT','Redo Thread',
'UN','User Name',
'TX', 'Transaction',
'TM', 'DML',
'UL', 'PL/SQL User Lock',
'DX', 'Distributed Xaction',
'CF', 'Control File',
'IS', 'Instance State',
'FS', 'File Set',
'IR', 'Instance Recovery',
'ST', 'Disk Space Transaction',
'TS', 'Temp Segment',
'IV', 'Library Cache Invalida-tion',
'LS', 'Log Start or Switch',
'RW', 'Row Wait',
'SQ', 'Sequence Number',
'TE', 'Extend Table',
'TT', 'Temp Table',
'Unknown') LockType,
rtrim(object_type) || ' ' || rtrim(owner) || '.' || object_name object_name,
decode(lmode, 0, 'None',
1, 'Null',
2, 'Row-S',
3, 'Row-X',
4, 'Share',
5, 'S/Row-X',
6, 'Exclusive', 'Unknown') LockMode,
decode(request, 0, 'None',
1, 'Null',
2, 'Row-S',
3, 'Row-X',
4, 'Share',
5, 'S/Row-X',
6, 'Exclusive', 'Unknown') RequestMode,
ctime, block b
from v$lock, all_objects
where sid > 6
and v$lock.id1 = all_objects.object_id;
會得到如下的結果!!
1 12 DML TABLE MISDORACLE.ZZRK121R Row-X None 3176 0
2 12 DML TABLE MISDORACLE.ZZRK121R1 Row-XNone 3176 0
3 12 DML TABLE MISDORACLE.ZZRK121R2 Row-X None 3176 0
4 12 DML TABLE MISDORACLE.ZZRK121R3 Row-X None 3176 0
鎖的級別太高啦 外來鍵 或者主鍵沒有建立索引!!
1 12 DML TABLE MISDORACLE.ZZRK121R Row-X None 3176 0
2 12 DML TABLE MISDORACLE.ZZRK121R1 Row-S None 3176 0
3 12 DML TABLE MISDORACLE.ZZRK121R2 Row-S None 3176 0
4 12 DML TABLE MISDORACLE.ZZRK121R3 Row-S None 3176 0
建立索引後的情況!!
T2 T1 | S | X | RS | RX | SRX | - |
S | Y | N | Y | N | N | Y |
X | N | N | N | N | N | Y |
RS | Y | N | Y | Y | Y | Y |
RX | N | N | Y | Y | N | Y |
SRX | N | N | Y | N | N | Y |
- | Y | Y | Y | Y | Y | Y |
鎖模式 | 鎖描述 | 解釋 | SQL操作 |
0 | none | ||
1 | NULL | 空 | Select |
2 | SS(Row-S) | 行級共享鎖,其他物件只能查詢這些資料行 | Select for update、Lock for update、Lock row share |
3 | SX(Row-X) | 行級排它鎖,在提交前不允許做DML操作 | Insert、Update、Delete、Lock row share |
4 | S(Share) | 共享鎖 | Create index、Lock share |
5 | SSX(S/Row-X) | 共享行級排它鎖 | Lock share row exclusive |
6 | X(Exclusive) | 排它鎖 | Alter table、Drop table、Drop index、Truncate table 、Lock exclusive |
導致死鎖的原因主要有兩個,一先外來鍵沒有使用索引,二是點陣圖的併發更新
[@more@]來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/9879835/viewspace-1003459/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 死鎖案例分析
- HashMap死鎖分析HashMap
- MySQL:一個死鎖分析 (未分析出來的死鎖)MySql
- GreatSQL 死鎖案例分析SQL
- 故障分析 | MySQL死鎖案例分析MySql
- SQLServer的死鎖分析(1):頁鎖SQLServer
- MySQL 死鎖問題分析MySql
- ORACLE 死鎖分析過程Oracle
- Sqlserver分析死鎖問題SQLServer
- 線上死鎖問題分析
- MySQL 死鎖日誌分析MySql
- MySQL鎖等待與死鎖問題分析MySql
- MySQL批量更新死鎖案例分析MySql
- Oracle死鎖原因產生分析Oracle
- MySQL死鎖系列-常見加鎖場景分析MySql
- MySQL:RR分析死鎖一列MySql
- 線上BUG:MySQL死鎖分析實戰MySql
- MySQL死鎖分析與解決之路MySql
- 精算業務死鎖的具體分析
- Java鎖——死鎖Java
- 死鎖
- 這樣分析一個死鎖問題
- MySQL · 答疑解惑 · 物理備份死鎖分析MySql
- SQ死鎖及死鎖的解決
- 面試官:什麼是死鎖?怎麼排查死鎖?怎麼避免死鎖?面試
- 什麼是死鎖?如何解決死鎖?
- 殺死Oracle死鎖程式Oracle
- oracle 死鎖Oracle
- 一次 MySQL 線上死鎖分析實戰MySql
- oracle deadlock死鎖trace file分析之一Oracle
- MySQL死鎖案例分析一(先delete,再insert,導致死鎖)MySqldelete
- 面試:什麼是死鎖,如何避免或解決死鎖;MySQL中的死鎖現象,MySQL死鎖如何解決面試MySql
- 檢視oracle死鎖程式並結束死鎖Oracle
- 例項詳解 Java 死鎖與破解死鎖Java
- MySQL死鎖系列-線上死鎖問題排查思路MySql
- 作業系統(5) 死鎖的概念 死鎖產生的必要條件 死鎖的處理策略 預防死鎖 避免死鎖 死鎖的檢測和解除 銀行家演算法作業系統演算法
- MySQL 死鎖和鎖等待MySql
- 故障分析 | 從 Insert 併發死鎖分析 Insert 加鎖原始碼邏輯原始碼