MySQL死锁:Lock wait timeout exceeded; try restarting transaction
使用框架:Spring3.0 + Hibernate3.5 + MySQL
使用Spring事务管理器对事务管理,Service服务中使用@Transactional注解声明要使用的事务管理器
1、下位机每隔100毫秒向上位机发送心跳,会根据主键对itemgroup表先Select查询,再执行update更新操作(更新last_online_time时间戳字段),update语句如下:
UPDATE itemgroup SET alarm_num=?, downline_times=?, fault_num=?, last_check_time=?, last_downline_time=?, last_notice_time=?, last_online_time=?, online_duration=? WHERE id=?
2、上位机每隔10秒会对itemgroup表进行Select查询,并执行update操作(更新last_check_time时间戳字段),update语句如下:
UPDATE itemgroup SET alarm_num=?, downline_times=?, fault_num=?, last_check_time=?, last_downline_time=?, last_notice_time=?, last_online_time=?, online_duration=? WHERE id=?
经过四五十分钟,出现
“org.springframework.jdbc.UncategorizedSQLException: Hibernate flushing: Could not execute JDBC batch update; uncategorized SQLException for SQL [update itemgroup set alarm_num=?, downline_times=?, fault_num=?, last_check_time=?, last_downline_time=?, last_notice_time=?, last_online_time=?, online_duration=? where id=?]; SQL state [41000]; error code [1205]; Lock wait timeout exceeded; try restarting transaction; nested exception is java.sql.BatchUpdateException: Lock wait timeout exceeded; try restarting transaction”异常
执行MySQL show full processlist命令,发现存在死锁。请问该问题如何解决?谢谢!!!!