-
Notifications
You must be signed in to change notification settings - Fork 325
麻烦问下4和18的情况有办法避免吗? #12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
一般来说有几种方法可以避免这个死锁:
|
我的这个id是主键,这个没办法修改,之前用INSERT ... ON DUPLICATE KEY UPDATE已经发现被锁住一次了,目前只能通过分布式锁禁止用户同时发起登录行为。 |
不知道你的重现步骤是怎么样的?我之前有重现过案例18,你可以看下这个脚本,README 里写了我的重现步骤:https://github.com/aneasystone/mysql-deadlocks/blob/master/docker/db/t18.sql |
我就是按照你的脚本测试的,是不是跟事务隔离级别有关?我的库是读提交 |
回答与当前 case 无关. 不过复现死锁真的与隔离级别有关.不同的隔离级别会产生不同的加锁情况.特别是 RR 与 RC 级别的区别. |
case18我本地并不能复现。相反,如果把id换成unique key,就能稳定复现。
|
你好,我遇到4和18的情况,事务隔离级别已经设置为read committed,但是无法完全避免此类情况,目前只能通过分布式锁保证更新不在同一条id上进行,有办法通过调整数据库操作避免此种情况吗?
The text was updated successfully, but these errors were encountered: