MySQL死鎖案例一(回滾導致死鎖)
測試環境:MySQL 5.7.26
建立測試表:
create table t1 (id int not null,name int,primary key(id),unique key(name));
死鎖模擬過程如下:
會話1rollback之後會話2和3出現死鎖,innodb選擇kill掉會話3並丟擲:
ERROR 1213 (40001): Deadlock found when trying to get lock; try restarting transaction
死鎖日誌如下:
LATEST DETECTED DEADLOCK ------------------------ 2020-08-21 16:56:19 0x7f39023e7700 *** (1) TRANSACTION: TRANSACTION 26163597, ACTIVE 46 sec inserting, thread declared inside InnoDB 1 mysql tables in use 1, locked 1 LOCK WAIT 4 lock struct(s), heap size 1136, 2 row lock(s), undo log entries 1 MySQL thread id 208, OS thread handle 139883056465664, query id 3837074 localhost root update insert into t1 values(2018,255) *** (1) WAITING FOR THIS LOCK TO BE GRANTED: RECORD LOCKS space id 831 page no 4 n bits 72 index name of table `test`.`t1` trx id 26163597 lock_mode X insert intention waiting Record lock, heap no 1 PHYSICAL RECORD: n_fields 1; compact format; info bits 0 0: len 8; hex 73757072656d756d; asc supremum;; *** (2) TRANSACTION: TRANSACTION 26163678, ACTIVE 6 sec inserting, thread declared inside InnoDB 1 mysql tables in use 1, locked 1 4 lock struct(s), heap size 1136, 2 row lock(s), undo log entries 1 MySQL thread id 210, OS thread handle 139882827511552, query id 3837238 localhost root update insert into t1 values(2019,255) *** (2) HOLDS THE LOCK(S): RECORD LOCKS space id 831 page no 4 n bits 72 index name of table `test`.`t1` trx id 26163678 lock mode S Record lock, heap no 1 PHYSICAL RECORD: n_fields 1; compact format; info bits 0 0: len 8; hex 73757072656d756d; asc supremum;; *** (2) WAITING FOR THIS LOCK TO BE GRANTED: RECORD LOCKS space id 831 page no 4 n bits 72 index name of table `test`.`t1` trx id 26163678 lock_mode X insert intention waiting Record lock, heap no 1 PHYSICAL RECORD: n_fields 1; compact format; info bits 0 0: len 8; hex 73757072656d756d; asc supremum;; *** WE ROLL BACK TRANSACTION (2)
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/30135314/viewspace-2713746/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- MySQL死鎖案例二(自增列導致死鎖)MySql
- MySQL死鎖案例分析一(先delete,再insert,導致死鎖)MySqldelete
- mysql insert導致死鎖MySql
- 【MySQL】Merge Index導致死鎖MySqlIndex
- MySQL:Innodb 一個死鎖案例MySql
- 【MySQL】死鎖案例之六MySql
- 【MySQL】死鎖案例之七MySql
- 【MySQL】死鎖案例之八MySql
- [20180801]insert導致死鎖.txt
- pthread_once導致死鎖thread
- MySQL批量更新死鎖案例分析MySql
- 故障分析 | MySQL死鎖案例分析MySql
- 剖析6個MySQL死鎖案例的原因以及死鎖預防策略MySql
- 死鎖案例二
- 死鎖案例三
- 死鎖案例分析
- MySQL 死鎖和鎖等待MySql
- MySQL:死鎖一例MySql
- MySQL:一個死鎖分析 (未分析出來的死鎖)MySql
- GreatSQL 死鎖案例分析SQL
- MySQL死鎖案例 – Learn. Write. Repeat.MySql
- mysql行鎖和死鎖檢測MySql
- Mysql 兩階段鎖和死鎖MySql
- 面試:什麼是死鎖,如何避免或解決死鎖;MySQL中的死鎖現象,MySQL死鎖如何解決面試MySql
- mysql同一個事務中update,insert導致死鎖問題分析解決MySql
- Oracle死鎖一例(ORA-00060),鎖表導致的業務死鎖問題Oracle
- MySQL死鎖系列-線上死鎖問題排查思路MySql
- MySQL 死鎖解決MySql
- MySQL解決死鎖MySql
- MySQL死鎖問題MySql
- MySQL:RR分析死鎖一列MySql
- MySQL鎖等待與死鎖問題分析MySql
- mysql死鎖最佳化MySql
- MySQL 死鎖問題分析MySql
- Mysql如何處理死鎖MySql
- MySQL列印死鎖日誌MySql
- MySQL:MTS和mysqldump死鎖MySql
- MySQL:RR模式下死鎖一列MySql模式