mybatisplus写入异常

Viewed 19

使用 mybatisplussave 时,jdbc 连接有 sessionVariables=group_commit=async_mode 参数时正常,没有或者 off_mode 时会报错,把语句拿出来直接执行时没问题的,使用 group_commit 会有延迟,需要实时生效。

Doris版本2.1.10

org.springframework.jdbc.UncategorizedSQLException: 
### Error updating database.  Cause: java.sql.SQLException: errCode = 2, detailMessage = Unexpected exception: -1
### The error may exist in xxMapper.java (best guess)
### The error may involve xxMapper.insert-Inline
### The error occurred while setting parameters
### SQL: INSERT INTO xx  ( id, dt)  VALUES (  ?, ?  )
### Cause: java.sql.SQLException: errCode = 2, detailMessage = Unexpected exception: -1
; uncategorized SQLException; SQL state [HY000]; error code [1105]; errCode = 2, detailMessage = Unexpected exception: -1

	at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:94)
	at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:347)
	at jdk.proxy2/jdk.proxy2.$Proxy128.insert(Unknown Source)
	at org.mybatis.spring.SqlSessionTemplate.insert(SqlSessionTemplate.java:224)
	at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.execute(MybatisMapperMethod.java:59)
	at com.baomidou.mybatisplus.core.override.MybatisMapperProxy$PlainMethodInvoker.invoke(MybatisMapperProxy.java:155)
	at com.baomidou.mybatisplus.core.override.MybatisMapperProxy.invoke(MybatisMapperProxy.java:92)
	at jdk.proxy2/jdk.proxy2.$Proxy131.insert(Unknown Source)
	at com.baomidou.mybatisplus.extension.repository.IRepository.save(IRepository.java:37)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:359)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:196)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
	at com.baomidou.dynamic.datasource.aop.DynamicDataSourceAnnotationInterceptor.invoke(DynamicDataSourceAnnotationInterceptor.java:57)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:184)
	at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:728)

mybatis-plus依赖

        <!-- Mybatis -->
        <dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>mybatis-plus-spring-boot3-starter</artifactId>
            <version>3.5.11</version>
        </dependency>
        <dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>mybatis-plus-jsqlparser</artifactId>
            <version>3.5.11</version>
        </dependency>
        <dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>dynamic-datasource-spring-boot3-starter</artifactId>
            <version>4.3.1</version>
        </dependency>
1 Answers
  1. Doris 具体的版本信息:show backends; 看version
  2. 如果想要数据立即可见,使用 group commit 的同步模式
  3. 这个报错不太明显,试试将回退关掉看看报什么错:set enable_fallback_to_original_planner = false;(需要和sql 在同一个session。或者全局开启进行测试 set global enable_fallback_to_original_planner = false; 全局开启)

同时需要提供fe.log 中详细的报错信息,以上异常栈都是你们自己程序打出来的