毕设系统问题集
1.The remote endpoint was in state [TEXT_FULL_MRITIN6] which is an invalid state for calledmethod
产生原因:同时有多个线程调用了this.session.getBasicRemote( ) .sendText(msg)
解决:synchronized(this.session)
2.重复推送,推测跟新闻列表的时间顺序不对有关
等待线上日志反馈......
日志反馈:时间顺序正确,推测是线程同步问题,加锁的地方有问题,修改静态变量发生了线程不安全。
解决:synchronized 具体service方法的 try catch块问题解决
3.SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@6b3a9668] was not registered for synchronization because synchronization is not active
解决:用@Transactional给定时方法开启事务
4. 负载均衡的其他容器请求不到静态文件
解决:轮询策略改为ip_hash
5. 线上日志显示反复插入重复数据
2022-03-31 10:58:42.329 INFO 1 --- [My-Async-ThreadPool-2-10] c.m.I.S.MultithreadScheduleTask : 更新数据库的国内外新闻信息失败! ### Error updating database. Cause: java.sql.SQLIntegrityConstraintViolationException: Duplicate entry '江苏新增本土确诊病例5例和本土无症状感染者41' for key 'epidemic_news.PRIMARY' ### The error may exist in com/major/IEMSystem/mapper/EpidemicNewsMapper.java (best guess) ### The error may involve com.major.IEMSystem.mapper.EpidemicNewsMapper.insert-Inline ### The error occurred while setting parameters ### SQL: INSERT INTO epidemic_news ( event_description, event_time, event_url, site_name ) VALUES ( ?, ?, ?, ? ) ### Cause: java.sql.SQLIntegrityConstraintViolationException: Duplicate entry '江苏新增本土确诊病例5例和本土无症状感染者41' for key 'epidemic_news.PRIMARY' ; Duplicate entry '江苏新增本土确诊病例5例和本土无症状感染者41' for key 'epidemic_news.PRIMARY'; nested exception is java.sql.SQLIntegrityConstraintViolationException: Duplicate entry '江苏新增本土确诊病例5例 和本土无症状感染者41' for key 'epidemic_news.PRIMARY' 2022-03-31 10:59:42.393 INFO 1 --- [My-Async-ThreadPool-2-11] c.m.I.S.MultithreadScheduleTask : 更新数据库的国内外新闻信息失败! ### Error updating database. Cause: java.sql.SQLIntegrityConstraintViolationException: Duplicate entry '江苏新增本土确诊病例5例和本土无症状感染者41' for key 'epidemic_news.PRIMARY' ### The error may exist in com/major/IEMSystem/mapper/EpidemicNewsMapper.java (best guess) ### The error may involve com.major.IEMSystem.mapper.EpidemicNewsMapper.insert-Inline ### The error occurred while setting parameters ### SQL: INSERT INTO epidemic_news ( event_description, event_time, event_url, site_name ) VALUES ( ?, ?, ?, ? )
排查问题:
首先排除后端逻辑错误------------因为只有这一条数据出错
主键(event_description)值已存在,又因为插入逻辑是根据event_time的值确定的,遂去数据库找到这条数据,发现时间比待插入的这条数据的event_time小
结论:百度的接口有问题,同一条新闻的时间,有可能发生更改(属实离谱!!!)
解决:把数据库的主键改为复合主键(event_description,event_time)
6.MySQL死锁
### Error updating database. Cause: com.mysql.cj.jdbc.exceptions.MySQLTransactionRollbackException: Deadlock found when trying to get lock; try restarting transaction ### The error may exist in com/major/IEMSystem/mapper/ChinaHistoryDataMapper.java (best guess) ### The error may involve com.major.IEMSystem.mapper.ChinaHistoryDataMapper.update-Inline ### The error occurred while setting parameters ### SQL: UPDATE china_history_data SET date=?, today_confirm=?, today_dead=?, today_heal=?, today_input=?, today_suspect=?, today_exist_confirm=?, total_dead=?, total_heal=?, total_input=?, total_confirm=? WHERE date = ? ### Cause: com.mysql.cj.jdbc.exceptions.MySQLTransactionRollbackException: Deadlock found when trying to get lock; try restarting transaction
问题来源:两个开启事务的定时任务都执行了同一个表的update方法,导致其中一个事务加锁失败
解决:合并两个定时任务
7.adminUpdate失败
问题原因:定时任务的修改的数据跟主动更新的数据是同一行,主动更新呗被定时任务的事务更新覆盖
定时任务事务开启---定时任务读---主动更新读写---定时任务写---定时任务提交
解决:更改数据库表的结构,做水平拆分,使更新的数据不在同一行