当前使用版本(必填,否则不予处理)

3.5.1

该问题是如何引起的?(确定最新版也有问题再提!!!)

该异常为偶发,主要是进行大量多次综合业务查询请求(7张表数据),单次前端接口请求最多包含3张表,且并未做left join,而是依次查询代码组合。异常出现在很多普通查询,批量查询,对象为属性为常规varchar,bigint,int类型,也有部分对象包含json类型属性(采用数组接收)。

重现步骤(如果有就写完整)

报错信息

异常随机出现在某次查询:

Error querying database. Cause: java.util.ConcurrentModificationException

The error may exist in com/**/dao/mapper/ProductAttributeMapper.java (best guess)

The error may involve com.**.mapper.ProductAttributeMapper.selectBatchIds

The error occurred while handling results

SQL: SELECT id,product_line_id,code,cn_name,en_name,version,deleted,create_by,update_by,create_time,update_time,ext1,ext2 FROM product_attribute WHERE id IN ( ? , ? ) AND deleted=0

Cause: java.util.ConcurrentModificationException

at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:96)
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:441)
at com.sun.proxy.$Proxy167.selectList(Unknown Source)
at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:224)
at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.executeForMany(MybatisMapperMethod.java:166)
at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.execute(MybatisMapperMethod.java:77)
at com.baomidou.mybatisplus.core.override.MybatisMapperProxy$PlainMethodInvoker.invoke(MybatisMapperProxy.java:148)
at com.baomidou.mybatisplus.core.override.MybatisMapperProxy.invoke(MybatisMapperProxy.java:89)
at com.sun.proxy.$Proxy168.selectBatchIds(Unknown Source)
at com.baomidou.mybatisplus.extension.service.IService.listByIds(IService.java:301)
at com.baomidou.mybatisplus.extension.service.IService$$FastClassBySpringCGLIB$$f8525d18.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:783)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:753)
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:137)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:753)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:698)
at com.**.dao.repository.impl.ProductAttributeRepositoryImpl$$EnhancerBySpringCGLIB$$2b863b04.listByIds(<generated>)
at com.**.service.ProductContactAttributeService.listByCondition(ProductContactAttributeService.java:329)

Error querying database. Cause: java.util.ConcurrentModificationException

The error may exist in com/**/dao/mapper/ProductContactAttributeMapper.java (best guess)

The error may involve com.**.dao.mapper.ProductContactAttributeMapper.selectList

The error occurred while handling results

SQL: SELECT id,product_id,attribute_id,alias,attribute_type,weight_measure,unit_name,offline_log,transfer_granularity,attribute_value_pattern,attribute_fixed_values,attribute_range_values,meal_sale,description,backup,parent_id,version,deleted,create_by,update_by,create_time,update_time,ext1,ext2 FROM product_contact_attribute WHERE (product_id = ? AND attribute_type = ? AND backup = ?) ORDER BY create_time DESC

Cause: java.util.ConcurrentModificationException

at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:96)
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:441)
at com.sun.proxy.$Proxy167.selectList(Unknown Source)
at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:224)
at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.executeForMany(MybatisMapperMethod.java:166)
at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.execute(MybatisMapperMethod.java:77)
at com.baomidou.mybatisplus.core.override.MybatisMapperProxy$PlainMethodInvoker.invoke(MybatisMapperProxy.java:148)
at com.baomidou.mybatisplus.core.override.MybatisMapperProxy.invoke(MybatisMapperProxy.java:89)
at com.sun.proxy.$Proxy178.selectList(Unknown Source)
at com.baomidou.mybatisplus.extension.service.IService.list(IService.java:370)
at com.**.dao.repository.impl.ProductContactAttributeRepositoryImpl.listByProductIdAndAttributeTypeAndBackup(ProductContactAttributeRepositoryImpl.java:113)
at com.**.dao.repository.impl.ProductContactAttributeRepositoryImpl$$FastClassBySpringCGLIB$$5fbbd7f6.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:783)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:753)
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:137)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:753)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:698)
at com.**.dao.repository.impl.ProductContactAttributeRepositoryImpl$$EnhancerBySpringCGLIB$$596207e4.listByProductIdAndAttributeTypeAndBackup(<generated>)
at com.**.service.ProductContactAttributeService.listByCondition(ProductContactAttributeService.java:322)

Comment From: miemieYaho

你有排查过是不是你的代码问题吗?有了解java.util.ConcurrentModificationException这是什么异常吗?

Comment From: fahualei

当然了解了这个异常,java中集合相关的异常,正因为如此该异常由框架抛出来的,且注意是sql查询执行时抛出,单次接口代码是没有问题,逻辑并不复杂,且做过并发。综合多个接口还在排查,这相当异步了

---原始邮件--- 发件人: @.> 发送时间: 2022年7月22日(周五) 中午11:20 收件人: @.>; 抄送: @.**@.**>; 主题: Re: [baomidou/mybatis-plus] java.util.ConcurrentModificationException异常 (Issue #4666)

你有排查过是不是你的代码问题吗?有了解java.util.ConcurrentModificationException这是什么异常吗?

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

Comment From: miemieYaho

框架又不会对集合内元素进行删改

Comment From: fahualei

结果集不是框架返回吗?异常就是映射结果集报错了呀

---原始邮件--- 发件人: @.> 发送时间: 2022年7月22日(周五) 下午2:13 收件人: @.>; 抄送: @.**@.**>; 主题: Re: [baomidou/mybatis-plus] java.util.ConcurrentModificationException异常 (Issue #4666)

框架又不会对集合内元素进行删改

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

Comment From: miemieYaho

MyBatis-Plus java.util.ConcurrentModificationException异常

Comment From: fahualei

这个有啥问题呢?一个传参而已,也是框架提供的传批量id查询。你不会觉得我把传入的集合进行修改吧。这没有的,不过我用的Arrays.asList包装的集合传入

---原始邮件--- 发件人: @.> 发送时间: 2022年7月22日(周五) 下午3:32 收件人: @.>; 抄送: @.**@.**>; 主题: Re: [baomidou/mybatis-plus] java.util.ConcurrentModificationException异常 (Issue #4666)

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

Comment From: miemieYaho

数据封装和sq执行的活都是mybatis在干,你觉得会有问题吗?

Comment From: fahualei

不好意思~我排查到了问题,是自定义了实现org.apache.ibatis.logging.Log这个日志打印,有集合操作。