# 先用 for update 锁住该条数据
begin;
select * from xxx_db.xxxx_tab where a = '107' for update;
update xxx_db.xxxx_tab set current_version = '5' where a = '107';
# 等代码的事务执行一半卡住时,再commit => 让代码的乐观锁生效,回滚事务
# commit;
MySQL | 黑盒情况下,锁表测试代码乐观锁下的事务回滚
最新推荐文章于 2024-07-21 19:06:05 发布