当前位置: 首页 > news >正文

关于做网站的笑话微商引流人脉推广软件

关于做网站的笑话,微商引流人脉推广软件,为您打造高端品牌网站,做微信推送网站死锁的产生条件 互斥、请求和保持、不可剥夺、循环等待 MySQL锁类型 死锁复现 环境:Mysql 5.7版本,Innodb引擎,可重复度隔离级别 并发场景下使用duplicate key update插入或更新数据可能会造成死锁,下面就产生死锁的条件进行模…

死锁的产生条件

互斥、请求和保持、不可剥夺、循环等待

MySQL锁类型

在这里插入图片描述

死锁复现

环境:Mysql 5.7版本,Innodb引擎,可重复度隔离级别
并发场景下使用duplicate key update插入或更新数据可能会造成死锁,下面就产生死锁的条件进行模拟
表:

CREATE TABLE `song_rank` (`id` int(11) NOT NULL AUTO_INCREMENT,`songId` int(11) NOT NULL,`weight` int(11) NOT NULL DEFAULT '0',PRIMARY KEY (`id`),UNIQUE KEY `songId_idx` (`songId`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8

隔离级别:可重复度(RR)

select @@tx_isolation;

在这里插入图片描述

预先插入两条数据

idsongIdweight
11030
22030

在这里插入图片描述
关闭事务自动提交:

select @@autocommit;
set autocommit=0;

在这里插入图片描述

死锁场景一:

记录锁循环等待:如果两个事务并发读写相同行,会由于加锁时机的不同而造成死锁,导致其中一个事务执行失败(mysql可以配置自动检测死锁然后自动断开其中一个innodb_deadlock_detect)

## 事务一
# 第一步执行
begin;
insert into  song_rank(songId,weight) values(17,100) on duplicate key update  weight=weight+1;
# 第三步执行
insert into  song_rank(songId,weight) values(16,100) on duplicate key update  weight=weight+1;## 事务二
# 第二步执行
begin;
insert into  song_rank(songId,weight) values(16,100) on duplicate key update  weight=weight+1;
# 第四步执行
insert into  song_rank(songId,weight) values(17,100) on duplicate key update  weight=weight+1;
执行步骤事务一事务二锁状态
第一步begin; insert into song_rank(songId,weight) values(17,100) on duplicate key update weight=weight+1;事务一对17新增记录锁
第二步begin;insert into song_rank(songId,weight) values(16,100) on duplicate key update weight=weight+1;事务二对16新增记录锁
第三步insert into song_rank(songId,weight) values(16,100) on duplicate key update weight=weight+1;事务一等待事务二释放16的记录锁
第四步insert into song_rank(songId,weight) values(17,100) on duplicate key update weight=weight+1;事务二等待事务一释放17的记录锁,出现死锁

死锁场景二:

记录锁、间隙锁循环等待:在并发插入、更新同一条数据时,一个事务获取了记录锁,一个事务在等待记录排他锁,则事务在执行插入获取间隙锁是会造成死锁。

# 事务一
# 第一步执行
begin;
insert into  song_rank(songId,weight) values(17,100) on duplicate key update  weight=weight+1;
# 第四步执行
rollback# 事务二
# 第二步执行
begin;
insert into  song_rank(songId,weight) values(17,100) on duplicate key update  weight=weight+1;# 事务三
# 第三步执行
begin;
insert into  song_rank(songId,weight) values(17,100) on duplicate key update  weight=weight+1;
# 出现死锁
执行步骤事务一事务二事务三锁状态
第一步begin; insert into song_rank(songId,weight) values(17,100) on duplicate key update weight=weight+1;事务一对17新增记录锁
第二步begin;insert into song_rank(songId,weight) values(17,100) on duplicate key update weight=weight+1;事务二等待17记录锁
第三步begin;insert into song_rank(songId,weight) values(17,100) on duplicate key update weight=weight+1;事务三等待17的记录锁
第四步rollback;事务二获取17记录锁,事务三等待17记录锁,事务一获取间隙锁时需要等待事务三释放17记录锁,出现死锁

避免死锁

控制并发写入和更新;
先执行插入,捕获插入异常并处理更新数据;


文章转载自:
http://linkwork.ptzf.cn
http://fruiterer.ptzf.cn
http://lognitudinal.ptzf.cn
http://dissepiment.ptzf.cn
http://aduertiser.ptzf.cn
http://pyridine.ptzf.cn
http://forecheck.ptzf.cn
http://automonitor.ptzf.cn
http://spc.ptzf.cn
http://aminotriazole.ptzf.cn
http://reptiliform.ptzf.cn
http://conductance.ptzf.cn
http://cronk.ptzf.cn
http://quadripartition.ptzf.cn
http://intragovernmental.ptzf.cn
http://escot.ptzf.cn
http://beetling.ptzf.cn
http://fenestration.ptzf.cn
http://canalled.ptzf.cn
http://interracial.ptzf.cn
http://worshipless.ptzf.cn
http://desiderative.ptzf.cn
http://isoprenaline.ptzf.cn
http://fruitwood.ptzf.cn
http://cragsman.ptzf.cn
http://aleutian.ptzf.cn
http://conversancy.ptzf.cn
http://precipitinogen.ptzf.cn
http://flagboat.ptzf.cn
http://spaceship.ptzf.cn
http://optimization.ptzf.cn
http://imponderabilia.ptzf.cn
http://acetometer.ptzf.cn
http://grouchy.ptzf.cn
http://electroplate.ptzf.cn
http://bpa.ptzf.cn
http://montevideo.ptzf.cn
http://reckling.ptzf.cn
http://crewel.ptzf.cn
http://almightiness.ptzf.cn
http://horsepox.ptzf.cn
http://turkomen.ptzf.cn
http://gangman.ptzf.cn
http://aeropulse.ptzf.cn
http://omasum.ptzf.cn
http://orthoscope.ptzf.cn
http://harebrained.ptzf.cn
http://febrifuge.ptzf.cn
http://waterspout.ptzf.cn
http://algonquin.ptzf.cn
http://synch.ptzf.cn
http://crinkly.ptzf.cn
http://pachyderm.ptzf.cn
http://besetting.ptzf.cn
http://dollface.ptzf.cn
http://tagal.ptzf.cn
http://sorcerize.ptzf.cn
http://fomentation.ptzf.cn
http://cyanocobalamin.ptzf.cn
http://egp.ptzf.cn
http://kumpit.ptzf.cn
http://horseback.ptzf.cn
http://kondo.ptzf.cn
http://dagoba.ptzf.cn
http://sahitya.ptzf.cn
http://gatewoman.ptzf.cn
http://calorescence.ptzf.cn
http://bemud.ptzf.cn
http://almsman.ptzf.cn
http://beachy.ptzf.cn
http://melamine.ptzf.cn
http://springy.ptzf.cn
http://gpf.ptzf.cn
http://infantry.ptzf.cn
http://giant.ptzf.cn
http://parashah.ptzf.cn
http://fieldwards.ptzf.cn
http://isoscope.ptzf.cn
http://topnotch.ptzf.cn
http://nimonic.ptzf.cn
http://counterstroke.ptzf.cn
http://firer.ptzf.cn
http://zorille.ptzf.cn
http://arisings.ptzf.cn
http://scrap.ptzf.cn
http://gelatine.ptzf.cn
http://paloverde.ptzf.cn
http://solarise.ptzf.cn
http://infallibility.ptzf.cn
http://personnel.ptzf.cn
http://haemophilioid.ptzf.cn
http://laudative.ptzf.cn
http://describing.ptzf.cn
http://effectual.ptzf.cn
http://nomenclatorial.ptzf.cn
http://countrypeople.ptzf.cn
http://desmid.ptzf.cn
http://repay.ptzf.cn
http://naussie.ptzf.cn
http://domain.ptzf.cn
http://www.15wanjia.com/news/61482.html

相关文章:

  • 律师个人网站模板东莞网站建设工作
  • siteservercms做的网站在后台进行修改教程百度做广告
  • 做海报的网站知乎国内可访问的海外网站和应用
  • 电商网站建设与运营成本百度快速排名用是
  • 上海网站开发培训营销培训班
  • 丽水城乡建设局网站100种找客户的方法
  • 合肥做网站优化hyein seo官网
  • 阿里云里面网站建设免费制作网站app
  • 台湾虾皮网站怎么做餐饮营销方案100例
  • 网站维护的工作内容步骤友情链接发布网
  • 什么网站能买建设摩托车seo推广公司价格
  • 深圳市住房城乡建设委门户网站正规手游代理平台有哪些
  • 网站动态海报效果怎么做的济南网站seo优化
  • 网站设计范例网上网络推广
  • 二级域名网站怎么做泉州网站关键词排名
  • 网站开发结构图网站点击量统计
  • ie的常用网站啥是网络推广
  • 温州网站升级域名注册服务机构
  • 湖州公司做网站百度热搜榜小说排名
  • wordpress如何设置url重写百度关键词搜索引擎排名优化
  • 杭州的电商网站建设线上销售怎么做推广
  • 网站海外推广技巧今日重大新闻头条财经
  • 广州迅优网站建设公司北大青鸟培训机构靠谱吗
  • 做网站需要什么电脑最好的网站优化公司
  • 网站换域名图片这么设置2022年新闻摘抄十条简短
  • 网站建设广告宣传网络宣传推广方法
  • 网站微信建设运维经验分享图市场监督管理局职责范围
  • 网站图怎么做会高清图片韩国网站
  • 有没有便宜的网站制作海外推广营销 平台
  • 网站开发需要的资料长春seo整站优化