MySQL 死锁日志分析
2016-01-29 17:37
567 查看
------------------------
LATEST DETECTED DEADLOCK
------------------------
140824 1:01:24
*** (1) TRANSACTION:
TRANSACTION 110E, ACTIVE 73 sec starting index read ## 事务ID=110E,活跃了73s
mysql tables in use 1, locked 1
LOCK WAIT 3 lock struct(s), heap size 376, 2 row lock(s) ## 有2个行锁
MySQL thread id 1, OS thread handle 0x7f55ea639700, query id 81 localhost root updating ## 该事务的线程ID=1
delete from t1 where a=1 ## 这是当前事务执行的SQL
*** (1) WAITING FOR THIS LOCK TO BE GRANTED: ## 上面SQL等待的锁信息
RECORD LOCKS space id 12 page no 3 n bits 80 index `PRIMARY` of table `test`.`t1` trx id 110E lock_mode X locks rec but not gap waiting
Record lock, heap no 2 PHYSICAL RECORD: n_fields 4; compact format; info bits 32 ## 等待在主键上的page num=3上有加一个X锁(not gap waiting),锁80 bits
0: len 4; hex 80000001; asc ;;
1: len 6; hex 00000000110c; asc ;;
2: len 7; hex 0d000002350084; asc 5 ;;
3: len 4; hex 80000001; asc ;;
*** (2) TRANSACTION:
TRANSACTION 110C, ACTIVE 1716 sec starting index read, thread declared inside InnoDB 500 ## 事务ID=110C,活跃了1716s
mysql tables in use 1, locked 1
3 lock struct(s), heap size 376, 2 row lock(s), undo log entries 1 ## 3个锁,2个行锁,1个undo log
MySQL thread id 2, OS thread handle 0x7f563c05e700, query id 82 localhost root updating ## 该事务的线程ID=2
delete from t1 where a=3 ## 这是当前事务执行的SQL
*** (2) HOLDS THE LOCK(S): ## 这个事务持有的锁信息
RECORD LOCKS space id 12 page no 3 n bits 80 index `PRIMARY` of table `test`.`t1` trx id 110C lock_mode X locks rec but not gap
Record lock, heap no 2 PHYSICAL RECORD: n_fields 4; compact format; info bits 32 ## 在主键上的page num=3上已持有一个X锁(not gap),锁80 bits
0: len 4; hex 80000001; asc ;;
1: len 6; hex 00000000110c; asc ;;
2: len 7; hex 0d000002350084; asc 5 ;;
3: len 4; hex 80000001; asc ;;
*** (2) WAITING FOR THIS LOCK TO BE GRANTED: ## 同时这个事务还等待的锁信息
RECORD LOCKS space id 12 page no 3 n bits 80 index `PRIMARY` of table `test`.`t1` trx id 110C lock_mode X locks rec but not gap waiting
Record lock, heap no 3 PHYSICAL RECORD: n_fields 4; compact format; info bits 0 ## 同样等待在主键上的page num=3上有加一个X锁(not gap waiting),锁80 bits
0: len 4; hex 80000003; asc ;;
1: len 6; hex 000000000f71; asc q;;
2: len 7; hex ed0000022f0090; asc / ;;
3: len 4; hex 80000003; asc ;;
*** WE ROLL BACK TRANSACTION (1) ## 这里选择回滚了事务110E。
也就是说,这个死锁使用事务110E中的SQL没有执行,回滚了:
delete from t1 where a=1
而事务110C中的SQL是正常被执行的:
delete from t1 where a=3
LATEST DETECTED DEADLOCK
------------------------
140824 1:01:24
*** (1) TRANSACTION:
TRANSACTION 110E, ACTIVE 73 sec starting index read ## 事务ID=110E,活跃了73s
mysql tables in use 1, locked 1
LOCK WAIT 3 lock struct(s), heap size 376, 2 row lock(s) ## 有2个行锁
MySQL thread id 1, OS thread handle 0x7f55ea639700, query id 81 localhost root updating ## 该事务的线程ID=1
delete from t1 where a=1 ## 这是当前事务执行的SQL
*** (1) WAITING FOR THIS LOCK TO BE GRANTED: ## 上面SQL等待的锁信息
RECORD LOCKS space id 12 page no 3 n bits 80 index `PRIMARY` of table `test`.`t1` trx id 110E lock_mode X locks rec but not gap waiting
Record lock, heap no 2 PHYSICAL RECORD: n_fields 4; compact format; info bits 32 ## 等待在主键上的page num=3上有加一个X锁(not gap waiting),锁80 bits
0: len 4; hex 80000001; asc ;;
1: len 6; hex 00000000110c; asc ;;
2: len 7; hex 0d000002350084; asc 5 ;;
3: len 4; hex 80000001; asc ;;
*** (2) TRANSACTION:
TRANSACTION 110C, ACTIVE 1716 sec starting index read, thread declared inside InnoDB 500 ## 事务ID=110C,活跃了1716s
mysql tables in use 1, locked 1
3 lock struct(s), heap size 376, 2 row lock(s), undo log entries 1 ## 3个锁,2个行锁,1个undo log
MySQL thread id 2, OS thread handle 0x7f563c05e700, query id 82 localhost root updating ## 该事务的线程ID=2
delete from t1 where a=3 ## 这是当前事务执行的SQL
*** (2) HOLDS THE LOCK(S): ## 这个事务持有的锁信息
RECORD LOCKS space id 12 page no 3 n bits 80 index `PRIMARY` of table `test`.`t1` trx id 110C lock_mode X locks rec but not gap
Record lock, heap no 2 PHYSICAL RECORD: n_fields 4; compact format; info bits 32 ## 在主键上的page num=3上已持有一个X锁(not gap),锁80 bits
0: len 4; hex 80000001; asc ;;
1: len 6; hex 00000000110c; asc ;;
2: len 7; hex 0d000002350084; asc 5 ;;
3: len 4; hex 80000001; asc ;;
*** (2) WAITING FOR THIS LOCK TO BE GRANTED: ## 同时这个事务还等待的锁信息
RECORD LOCKS space id 12 page no 3 n bits 80 index `PRIMARY` of table `test`.`t1` trx id 110C lock_mode X locks rec but not gap waiting
Record lock, heap no 3 PHYSICAL RECORD: n_fields 4; compact format; info bits 0 ## 同样等待在主键上的page num=3上有加一个X锁(not gap waiting),锁80 bits
0: len 4; hex 80000003; asc ;;
1: len 6; hex 000000000f71; asc q;;
2: len 7; hex ed0000022f0090; asc / ;;
3: len 4; hex 80000003; asc ;;
*** WE ROLL BACK TRANSACTION (1) ## 这里选择回滚了事务110E。
也就是说,这个死锁使用事务110E中的SQL没有执行,回滚了:
delete from t1 where a=1
而事务110C中的SQL是正常被执行的:
delete from t1 where a=3
相关文章推荐
- 【转载】MySQL查询阻塞语句
- MySQL 通过mysql_config_editor更安全的登录数据库
- mysqlsla 分析mysql慢查询日志
- MySQL 主键冲突,无法插入数据
- mysql 分表 和 数据冗余
- MySQL不同库名相同表结构实现主从配置
- 通过keepalived实现 MySQL VIP 自动切换
- 安装mysql 5.5.14 报错
- MySQL ibdata1撑爆占满磁盘空间
- MySQL主从修复
- MySQL主从切换
- 查看MySQL还原出来的binlog日志中内容方法
- 【转载】MySQL 日志 undo | redo
- MySQL通过Binlog恢复删除的表
- mysqldump 参数说明
- MySQL复制
- MySQL Server-id的作用
- MySQL 简洁连接数据库方式
- Kill 所有MySQL进程
- MySQL SHOW 语句大全