Home > Database > Mysql Tutorial > 并发-请教一个mysql批量更新时的deadlock问题?

并发-请教一个mysql批量更新时的deadlock问题?

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-06 09:34:11
Original
1151 people have browsed it

mysql并发

数据是mysql 5.6 表引擎是innoDB,DAO是mybatis3

有个表,比如是订单-物品表,里面保存每个订单的所有物品清单
字段有:record_id(记录id,自增长),order_id(订单id),good_id(物品id)等其他字段..

有个数据同步的业务场景
需要在一个事务里
先根据order_id做删除操作,delete from xxx where order_id=xx
然后再批量增加订单-物品清单insert into xxx () values(),(),()
结果发现,经常在insert into 这发生deadlock。

同时,我这个事物所在的业务方法,是多线程并发进行的。就是有并发的线程,来更新不同的订单(的物品清单)

不知道如何解决。。。。

Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template