一、Bug内容:
----------- 异常信息 ------------
org.springframework.jdbc.UncategorizedSQLException: ### Error updating database. Cause: java.sql.SQLException: Multi-statement transaction required more than 'max_binlog_cache_size' bytes of storage; increase this mysqld variable and try again ### The error may involve com.vipshop.union.dao.TransactionDetailMapper.updateByExampleSelective-Inline ### The error occurred while setting parameters ### Cause: java.sql.SQLException: Multi-statement transaction required more than 'max_binlog_cache_size' bytes of storage; increase this mysqld variable and try again ; uncategorized SQLException for SQL []; SQL state [HY000]; error code [1197]; Multi-statement transaction required more than 'max_binlog_cache_size' bytes of storage; increase this mysqld variable and try again; nested exception is java.sql.SQLException: Multi-statement transaction required more than 'max_binlog_cache_size' bytes of storage; increase this mysqld variable and try again
二、Bug原因:
1、现有一个调度任务,某天的订单数据。
2、在处理中,程序采用一个事务,使用update来处理整个时间段内的订单。
3、由于订单量很大,造成事务中的数据库日志超出目前的配置,所以报错Multi-statement transaction required more than 'max_binlog_cache_size' bytes of storage
三、处理方案列表:
1、 修改调度任务配置,使得每次处理的日期跨度缩小。
2、 修改调度任务代码,拆分日期进行执行,分成多个事务。
3、 数据库修改配置,增大max_binlog_cache_size事务日志空间。
四、最终解决方案:
1、 采用时间段分区方式,将1天的时间,分成12个时间段。
2、 将每一个时间段的起始时间和结束时间,传入处理方法进行update处理,做为一个事务进行提交处理。