mysql - 有没有办法避免由于同一张表中的共享锁提升而导致死锁?
问题描述
我有一个 InnoDB 表“测试”,并且有两个事务查询该表。
第 1 节:
start transaction;
select * from test where testid = 200 lock in share mode;
第 2 节:
start transaction;
select * from test where testid = 200 lock in share mode;
第 1 节:
select * from test where testid = 200 for update;
-- Trying to get X lock and waits as session 2 already has a shared lock for this entry
第 2 节:
select * from test where testid = 200 for update;
--Deadlock occurs because of Shared lock of session 1
有没有办法摆脱这种情况?
解决方案
推荐阅读
- html - 设置 flex 值以在容器宽度较小时使标签正确显示?
- c# - C# tcpclient 没有写入套接字......或者我没有阅读所有的响应?
- excel - 如何使用 Excel VBA 有条件地添加和删除表中的某些行
- machine-learning - 类的混淆矩阵子集无法正常工作
- arrays - 如何创建由程序集中的寄存器定义的大小的初始化数组?
- python - 某个呼叫类别的第一次呼叫与同一呼叫类别的后续呼叫之间的调查分数差异
- javascript - 求解未知指数
- google-apps-script - 清除单元格时出错 - 简单脚本
- java - 无法加载我的世界插件
- sql - Rails:如何在 rails 的非 id 列上创建聚集索引?