事务过大,造成max_binlog_cache_size溢出

一、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处理,做为一个事务进行提交处理。

转载于:https://my.oschina.net/u/2485991/blog/533123

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值