Lock wait timeout exceeded; try restarting transaction
程序员文章站
2024-01-12 16:25:28
...
该错误是一个事务没有提交,而另一个事务开始。在循环插入或者更新数据的时候,使用多线程,但是没有保证线程安全的情况下回出现该问题。
<update id="updateByFileOcsIdSn">
update file_ocs_info SET assessment_sn=#{assessmentSn} where file_ocs_id=#{fileOcsId}
</update>
if (selfEvaluationApplicationFiles != null && selfEvaluationApplicationFiles.size() > 0) {
String finalSn1 = sn;
selfEvaluationApplicationFiles.parallelStream().forEach(self -> {
//获取fileocsId
String ocsId = self.getFileOcsId();
//根据ocsId插入架构师编号
fileOcsInfoMapper.updateByFileOcsIdSn(finalSn1, ocsId);
});
}
这里修改parallelStream为stream就可以
推荐阅读
-
Lock wait timeout exceeded; try restarting transaction
-
Lock wait timeout exceeded; try restarting transaction
-
Lock wait timeout exceeded; try restarting transaction
-
Mysql出现“ Lock wait timeout exceeded; try restarting trans
-
mysql报错:Deadlock found when trying to get lock; try restarting transaction的解决方法
-
数据库死锁的问题,Deadlock found when trying to get lock; try restarting transaction at Query.formatError
-
Lock wait timeout exceeded
-
Lock wait timeout exceeded; try restarting transaction
-
Mysql出现“ Lock wait timeout exceeded; try restarting trans
-
mysql提示 Lock wait timeout exceeded解决办法