Lock wait timeout exceeded; try restarting transaction
详细异常
UPDATE `rbac_user` t SET t.`login_count` = 0, `pwd_expire_day` = 90, `last_login_time` = TIMESTAMP '2024-10-25 10:39:08.000', `status` = '0', `update_user` = 'rbac_user_superuser', `update_date` = TIMESTAMP '2024-10-25 10:39:08.625' WHERE t.id IN ('03xqnu2hykkzt')
2024-10-25 10:39:18.685 [pool-8-thread-1] ERROR c.s.snest.engine.db.relationdb.RelationDBAccessor -数据源:main,执行SQL失败:Lock wait timeout exceeded; try restarting transaction
长事物导致更改rbac_user表的数据锁超时,事物没有结束所以拿不到锁。
经过排查到一段业务比较特殊,是批量插入,并且有可能导致长事物,并且会行锁rbac_user表
REPLACE INTO test_user (id, name, age, `password`, create_user, create_date, update_user, update_date) SELECT d.id, d.name, d.age, d.tenant_id, u1.name , d.create_date, u2.name, d.update_date FROM edo_user d, rbac_user u1, rbac_user u2 WHERE u1.id = d.create_user AND u2.id = d.update_user
待投批次数据统计定时任务出现异常: