首页 > 数据库技术 > 详细

为什么mysql默认情况下很难出现死锁?

时间:2021-05-17 00:02:50      阅读:28      评论:0      收藏:0      [点我收藏+]

因为mysql的死锁检查机制innodb_deadlock_detect,默认是打开的

 

CREATE TABLE `exception` (
  `id` int(11) NOT NULL,
  `c` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB;
insert into exception(id, c) values(1,1),(2,2),(3,3),(4,4);

 

在第一个客户端执行如下sql

 

客户端1 客户端2
begin; begin;
update exception set c=100 where id=1;  
  update exception set c=300 where id=2;
update exception set c=200 where id=2;  
  update exception set c=400 where id=1;
   
   

 

mysql死锁检查机制,会让死锁根本无法发生:

 

技术分享图片

 

为什么mysql默认情况下很难出现死锁?

原文:https://www.cnblogs.com/mkl34367803/p/14775073.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!