MyBatis 删除大量数据产生异常

之前做的一些流水数据,加了一个定时任务保留40天,看似简单的操作,但因数据堆积超过3个月数据量较大。再job执行的时候报了一个异常。

org.springframework.dao.TransientDataAccessResourceException: 
### Error updating database. Cause: com.mysql.jdbc.PacketTooBigException: Packet for query is too large (102096766 > 16777216). You can change this value on the server by setting the max_allowed_packet' variable.
### The error may involve defaultParameterMap
### The error occurred while setting parameters
### SQL: delete from antispam_pay_callback where id in 

大概意思就是:更新数据库时出错。原因:com.mysql.jdbc.packettoobigexception:用于查询的数据包太大(102096766>16777216)。您可以通过设置max_allowed_packet'变量在服务器上更改此值。

结论:当删除大量数据积压数据时,尽量采取分段删除。

猜你喜欢

转载自blog.csdn.net/weixin_41485592/article/details/88964805