[20180801]insert導致死鎖.txt
[20180801]insert導致死鎖.txt
--//連結http://www.itpub.net/thread-2104135-2-1.html的討論,自己有點疏忽了,插入主鍵相同也會導致死鎖.
--//自己按照連結%E5%BC%95%E8%B5%B7%E7%9A%84%E6%AD%BB%E9%94%81.html
--//自己測試看看:
1.環境:
SCOTT@test01p> @ ver1
PORT_STRING VERSION BANNER CON_ID
------------------------------ -------------- -------------------------------------------------------------------------------- ----------
IBMPC/WIN_NT64-9.1.0 12.1.0.1.0 Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production 0
2.測試:
--//session 1:
SCOTT@test01p> SCOTT@test01p> @ spid
SID SERIAL# PROCESS SERVER SPID PID P_SERIAL# C50
---------- ---------- ------------------------ --------- -------------------- ------- ---------- --------------------------------------------------
86 73 6388:6512 DEDICATED 6448 57 6 alter system kill session '86,73' immediate;
CREATE TABLE t1(ID NUMBER);
ALTER TABLE t1 ADD primary key (ID);
INSERT INTO t1 VALUES(1);
--//session 2:
SCOTT@test01p> @ spid
SID SERIAL# PROCESS SERVER SPID PID P_SERIAL# C50
---------- ---------- ------------------------ --------- -------------------- ------- ---------- --------------------------------------------------
237 59 6988:424 DEDICATED 5872 15 6 alter system kill session '237,59' immediate;
INSERT INTO t1 VALUES(2);
--//現在沒事沒有衝突.
--//回到session 1:
INSERT INTO t1 VALUES(2);
--//掛起,但是沒有死鎖.
--//回到session 2:
INSERT INTO t1 VALUES(1);
--//session 1出現如下提示:
SCOTT@test01p> INSERT INTO t1 VALUES(2);
INSERT INTO t1 VALUES(2)
*
ERROR at line 1:
ORA-00060: deadlock detected while waiting for resource
--//但是session 2一樣會掛起.因為主鍵衝突還存在.
--//session 1:
SCOTT@test01p> commit ;
Commit complete.
--//session 2:
SCOTT@test01p> INSERT INTO t1 VALUES(1);
INSERT INTO t1 VALUES(1)
*
ERROR at line 1:
ORA-00001: unique constraint (SCOTT.SYS_C0011640) violated
--//提示主鍵衝突.感覺應該在應用很少出現這樣的情況.
3.看看轉儲:
*** 2018-08-01 20:24:23.459
*** SESSION ID:(86.73) 2018-08-01 20:24:23.459
*** CLIENT ID:() 2018-08-01 20:24:23.459
*** SERVICE NAME:(test01p) 2018-08-01 20:24:23.459
*** MODULE NAME:(SQL*Plus) 2018-08-01 20:24:23.459
*** ACTION NAME:() 2018-08-01 20:24:23.459
*** CONTAINER ID:(3) 2018-08-01 20:24:23.459
*** 2018-08-01 20:24:23.459
DEADLOCK DETECTED ( ORA-00060 )
[Transaction Deadlock]
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
*** 2018-08-01 20:24:23.460
information may aid in determining the deadlock:
Deadlock graph:
---------Blocker(s)-------- ---------Waiter(s)---------
Resource Name process session holds waits process session holds waits
TX-00100015-0000060F-00000000-00000000 57 86 X 15 237 S
TX-00070013-00005F4E-00000000-00000000 15 237 X 57 86 S
session 86: DID 0001-0039-00000014 session 237: DID 0001-000F-0000000A
session 237: DID 0001-000F-0000000A session 86: DID 0001-0039-00000014
Rows waited on:
Session 86: no row
~~~~~~~~~~~~~~~~~~~
Session 237: no row
~~~~~~~~~~~~~~~~~~~~
----- Information for the OTHER waiting sessions -----
Session 237:
sid: 237 ser: 59 audsid: 26211525 user: 109/SCOTT
pdb: 3/TEST01P
flags: (0x100045) USR/- flags_idl: (0x1) BSY/-/-/-/-/-
flags2: (0x40009) -/-/INC
pid: 15 O/S info: user: oracle, term: XXX, ospid: 5872
image: ORACLE.EXE (SHAD)
client details:
O/S info: user: XXX\Administrator, term: XXX, ospid: 6988:424
machine: WORKGROUP\XXX program: sqlplus.exe
application name: SQL*Plus, hash value=3669949024
current SQL:
INSERT INTO t1 VALUES(1)
----- End of information for the OTHER waiting sessions -----
Information for THIS session:
----- Current SQL Statement for this session (sql_id=0s3pjym30ya3w) -----
INSERT INTO t1 VALUES(2)
===================================================
--//太長..
--//連結http://www.itpub.net/thread-2104135-1-1.html比較牛,有4個會話串在一起.
--//實際上我自己有點疑惑的地方:
Rows waited on:
Session 86: no row
Session 237: no row
--//no row,按照道理應該有行記錄.沒想到主鍵衝突會出現這樣的情況.
--//連結的錯誤應該類似這樣:
--//sesion 1:
SCOTT@test01p(86,73)> INSERT INTO t1 VALUES(1);
1 row created.
--//sesion 2:
SCOTT@test01p(237,59)> INSERT INTO t1 VALUES(2);
1 row created.
--//sesion 3:
SCOTT@test01p(161,69)> INSERT INTO t1 VALUES(3);
1 row created.
--//sesion 4:
SCOTT@test01p(156,71)> INSERT INTO t1 VALUES(4);
1 row created.
--//然後分別插入,就會分別掛起!!
--//sesion 1:
SCOTT@test01p(86,73)> INSERT INTO t1 VALUES(2);
--//sesion 2:
SCOTT@test01p(237,59)> INSERT INTO t1 VALUES(3);
--//sesion 3:
SCOTT@test01p(161,69)> INSERT INTO t1 VALUES(4);
--//sesion 4:
SCOTT@test01p(156,71)> INSERT INTO t1 VALUES(1);
*** 2018-08-01 20:50:46.479
DEADLOCK DETECTED ( ORA-00060 )
[Transaction Deadlock]
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
TX-000B0005-000013E2-00000000-00000000 57 86 X 58 156 S
TX-000A0007-000065E1-00000000-00000000 58 156 X 38 161 S
TX-00090002-00006203-00000000-00000000 38 161 X 15 237 S
TX-000F001B-00000835-00000000-00000000 15 237 X 57 86 S
session 86: DID 0001-0039-00000014 session 156: DID 0001-003A-0000000A
session 156: DID 0001-003A-0000000A session 161: DID 0001-0026-0000005B
session 161: DID 0001-0026-0000005B session 237: DID 0001-000F-0000000A
session 237: DID 0001-000F-0000000A session 86: DID 0001-0039-00000014
Rows waited on:
Session 86: no row
Session 156: no row
Session 161: no row
Session 237: no row
--//session 1(86) 阻塞 session 4(156)
--//session 4(156) 阻塞 session 3(161)
--//session 3(161) 阻塞 session 2(237)
--//session 2(237) 阻塞 session 1(86)
--//這樣就形成環.
--//不過好像對方的情況更復雜!!
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-2168918/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- mysql insert導致死鎖MySql
- MySQL死鎖案例分析一(先delete,再insert,導致死鎖)MySqldelete
- pthread_once導致死鎖thread
- 【MySQL】Merge Index導致死鎖MySqlIndex
- mysql同一個事務中update,insert導致死鎖問題分析解決MySql
- MySQL死鎖案例一(回滾導致死鎖)MySql
- MySQL死鎖案例二(自增列導致死鎖)MySql
- [20180907]insert+with+select.txt
- 故障分析 | 從 Insert 併發死鎖分析 Insert 加鎖原始碼邏輯原始碼
- [20181120]奇怪的insert語句.txt
- MySQL insert on duplicate key update 死鎖MySql
- mysql insert into ... select的鎖問題MySql
- insert引起的死鎖,起因主鍵衝突
- [20181030]模擬分散式事務掛起導致TX鎖爭用.txt分散式
- mysql的新建索引會導致insert被lockedMySql索引
- Oracle中的insert/insert all/insert firstOracle
- 社交“致死”的狼人殺
- 【程式設計師面試金典】20180801程式設計師面試
- INSERT...SELECT語句對查詢的表加鎖嗎
- MySQL:RR模式下insert也可能導致查詢慢MySql模式
- 20180801 出去走一走,遊一遊舟山
- [20190415]關於shared latch(共享栓鎖).txt
- insert into select
- [20210519]是否可能導致DML失效.txt
- @Transactional 中使用執行緒鎖導致了鎖失效執行緒
- insert all和insert first語句的用法
- MySQL Insert資料量過大導致報錯 MySQL server has gone awayMySqlServerGo
- 研究發現22%的AI生成醫療建議可能導致死亡或造成嚴重傷害AI
- insert images to a plot
- E - Insert or Erase
- SQL__INSERTSQL
- insert變數太多導致例項重啟ORA-00600、ORA-01006變數
- [20190211]rac下解鎖應用出現的阻塞.txt
- 研究發現印度自拍致死率全球第一
- 新冠肺炎致死率為何差異大?
- Oracle死鎖一例(ORA-00060),鎖表導致的業務死鎖問題Oracle
- ArrayList宣告,Add(), Insert();
- SQLite Insert 語句SQLite