apache / incubator-seata

:fire: Seata is an easy-to-use, high-performance, open source distributed transaction solution.
https://seata.apache.org/
Apache License 2.0
25.35k stars 8.78k forks source link

已经关闭的问题又出现了:Duplicate entry for key 'lock_table.PRIMARY' #6822

Closed changeAtLater closed 2 months ago

changeAtLater commented 2 months ago

#4872

我使用的是2.0.0的版本, 但出现了一样的问题, 先删后增报错, 尝试关闭lock_table的主键, 会发现两条row_key相同,branch_id不同的数据

user_role表就两个字段: user_id, role_id 删除sql: delete from user_role where user_id = 1 插入sql: insert into user_role (user_id, role_id) values (1, 2)

funky-eyes commented 2 months ago

确定是相同的xid? Are you sure it's the same xid?

changeAtLater commented 2 months ago

确定是相同的xid? Are you sure it's the same xid?

我退到1.7.0(server+client), 一样的问题

image

funky-eyes commented 2 months ago

由于为了解决insert场景没必要的锁重入问题,应该从1.5开始就改为了insert sql时忽略校验锁重入。什么样的业务场景需要先删除后插入呢? Since in order to solve the unnecessary lock reentry problem in the insert scene, it should be changed from 1.5 to ignore the check lock reentry when inserting SQL. What kind of business scenarios need to be deleted first and then inserted? https://github.com/apache/incubator-seata/pull/4237

changeAtLater commented 2 months ago

由于为了解决insert场景没必要的锁重入问题,应该从1.5开始就改为了insert sql时忽略校验锁重入。什么样的业务场景需要先删除后插入呢? Since in order to solve the unnecessary lock reentry problem in the insert scene, it should be changed from 1.5 to ignore the check lock reentry when inserting SQL. What kind of business scenarios need to be deleted first and then inserted? #4237

这是个用户和角色的关联表,里面只有两个主键,在编辑用户时,直接先删除该用户的角色,再重新插入,相比于判断哪些角色需要删除哪些需要插入,写起来更方便点.至于为什么这么写,那就是历史遗留问题了.

funky-eyes commented 2 months ago

由于为了解决insert场景没必要的锁重入问题,应该从1.5开始就改为了insert sql时忽略校验锁重入。什么样的业务场景需要先删除后插入呢? Since in order to solve the unnecessary lock reentry problem in the insert scene, it should be changed from 1.5 to ignore the check lock reentry when inserting SQL. What kind of business scenarios need to be deleted first and then inserted? #4237

这是个用户和角色的关联表,里面只有两个主键,在编辑用户时,直接先删除该用户的角色,再重新插入,相比于判断哪些角色需要删除哪些需要插入,写起来更方便点.至于为什么这么写,那就是历史遗留问题了.

有没有可能将这俩动作合并到一个本地事务去? Is it possible to combine these two actions into a local transaction?

funky-eyes commented 2 months ago

你可以把异常日志发出来看下吗?因为我看代码在1.5.2应该就已经修复了,server只要是1.5.2以上版本只要遇到唯一索引冲突就会返回false,而不是抛出异常。然后客户端会在第二次竞争锁的时候取消跳过check,然后就会重入锁了 Could you please share the exception log? I see that the code should have been fixed in version 1.5.2. In server versions 1.5.2 and above, encountering a unique index conflict should return false instead of throwing an exception. The client will then skip the check on the second lock attempt and re-enter the lock image

changeAtLater commented 2 months ago

合并到本地事务是指在更新用户和关联角色的方法上加个@Transactional?

24-09-06 12:23:29.320 [http-nio-9201-exec-4] ERROR i.s.r.d.e.AbstractDMLBaseExecutor - [executeAutoCommitTrue,151] - execute executeAutoCommitTrue error:io.seata.core.exception.RmTransactionException: branch register failed, xid: 10.8.8.29:8091:2648678384710869224, errMsg: TransactionException[branch register request failed. xid=10.8.8.29:8091:2648678384710869224, msg=Duplicate entry 'jdbc:mysql://172.16.1.123:37696/oas^^^sys_user_role^^^10000002_3' for key 'lock_table.PRIMARY'] 
java.sql.SQLException: io.seata.core.exception.RmTransactionException: branch register failed, xid: 10.8.8.29:8091:2648678384710869224, errMsg: TransactionException[branch register request failed. xid=10.8.8.29:8091:2648678384710869224, msg=Duplicate entry 'jdbc:mysql://172.16.1.123:37696/oas^^^sys_user_role^^^10000002_3' for key 'lock_table.PRIMARY'] 
    at io.seata.rm.datasource.ConnectionProxy.recognizeLockKeyConflictException(ConnectionProxy.java:161)
    at io.seata.rm.datasource.ConnectionProxy.processGlobalTransactionCommit(ConnectionProxy.java:252)
    at io.seata.rm.datasource.ConnectionProxy.doCommit(ConnectionProxy.java:230)
    at io.seata.rm.datasource.ConnectionProxy.lambda$commit$0(ConnectionProxy.java:188)
    at io.seata.rm.datasource.ConnectionProxy$LockRetryPolicy.execute(ConnectionProxy.java:344)
    at io.seata.rm.datasource.ConnectionProxy.commit(ConnectionProxy.java:187)
    at io.seata.rm.datasource.exec.AbstractDMLBaseExecutor.lambda$executeAutoCommitTrue$2(AbstractDMLBaseExecutor.java:146)
    at io.seata.rm.datasource.ConnectionProxy$LockRetryPolicy.doRetryOnLockConflict(ConnectionProxy.java:356)
    at io.seata.rm.datasource.exec.AbstractDMLBaseExecutor$LockRetryPolicy.execute(AbstractDMLBaseExecutor.java:188)
    at io.seata.rm.datasource.exec.AbstractDMLBaseExecutor.executeAutoCommitTrue(AbstractDMLBaseExecutor.java:144)
    at io.seata.rm.datasource.exec.AbstractDMLBaseExecutor.doExecute(AbstractDMLBaseExecutor.java:83)
    at io.seata.rm.datasource.exec.BaseTransactionalExecutor.execute(BaseTransactionalExecutor.java:125)
    at io.seata.rm.datasource.exec.ExecuteTemplate.execute(ExecuteTemplate.java:137)
    at io.seata.rm.datasource.exec.ExecuteTemplate.execute(ExecuteTemplate.java:56)
    at io.seata.rm.datasource.PreparedStatementProxy.execute(PreparedStatementProxy.java:55)
    at jdk.internal.reflect.GeneratedMethodAccessor427.invoke(Unknown Source)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at org.apache.ibatis.logging.jdbc.PreparedStatementLogger.invoke(PreparedStatementLogger.java:58)
    at jdk.proxy3/jdk.proxy3.$Proxy273.execute(Unknown Source)
    at org.apache.ibatis.executor.statement.PreparedStatementHandler.update(PreparedStatementHandler.java:48)
    at org.apache.ibatis.executor.statement.RoutingStatementHandler.update(RoutingStatementHandler.java:75)
    at org.apache.ibatis.executor.SimpleExecutor.doUpdate(SimpleExecutor.java:50)
    at org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:117)
    at org.apache.ibatis.executor.CachingExecutor.update(CachingExecutor.java:76)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:61)
    at jdk.proxy2/jdk.proxy2.$Proxy271.update(Unknown Source)
    at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:197)
    at org.apache.ibatis.session.defaults.DefaultSqlSession.insert(DefaultSqlSession.java:184)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:425)
    at jdk.proxy2/jdk.proxy2.$Proxy171.insert(Unknown Source)
    at org.mybatis.spring.SqlSessionTemplate.insert(SqlSessionTemplate.java:272)
    at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:62)
    at org.apache.ibatis.binding.MapperProxy$PlainMethodInvoker.invoke(MapperProxy.java:142)
    at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:86)
    at jdk.proxy2/jdk.proxy2.$Proxy175.batchInsertUserRole(Unknown Source)
    at com.project.oa.system.service.impl.SysUserServiceImpl.insertUserRole(SysUserServiceImpl.java:813)
    at com.project.oa.system.service.impl.SysUserServiceImpl.updateUser(SysUserServiceImpl.java:561)
    at com.project.oa.system.service.impl.SysUserServiceImpl.updateUserInGT(SysUserServiceImpl.java:622)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:343)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:196)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:751)
    at io.seata.spring.annotation.GlobalTransactionalInterceptor$2.execute(GlobalTransactionalInterceptor.java:208)
    at io.seata.tm.api.TransactionalTemplate.execute(TransactionalTemplate.java:128)
    at io.seata.spring.annotation.GlobalTransactionalInterceptor.handleGlobalTransaction(GlobalTransactionalInterceptor.java:205)
    at io.seata.spring.annotation.GlobalTransactionalInterceptor.invoke(GlobalTransactionalInterceptor.java:175)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:184)
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:751)
    at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:703)
    at com.project.oa.system.service.impl.SysUserServiceImpl$$SpringCGLIB$$0.updateUserInGT(<generated>)
    at com.project.oa.system.service.impl.SysUserServiceImpl.updateUserWithAd(SysUserServiceImpl.java:611)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:343)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:196)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:751)
    at io.seata.spring.annotation.GlobalTransactionalInterceptor.invoke(GlobalTransactionalInterceptor.java:181)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:184)
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:751)
    at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:703)
    at com.project.oa.system.service.impl.SysUserServiceImpl$$SpringCGLIB$$0.updateUserWithAd(<generated>)
    at com.project.oa.system.controller.SysUserController.edit(SysUserController.java:198)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:343)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:196)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:751)
    at org.springframework.aop.aspectj.AspectJAfterThrowingAdvice.invoke(AspectJAfterThrowingAdvice.java:64)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:173)
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:751)
    at org.springframework.aop.framework.adapter.AfterReturningAdviceInterceptor.invoke(AfterReturningAdviceInterceptor.java:57)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:173)
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:751)
    at org.springframework.aop.framework.adapter.MethodBeforeAdviceInterceptor.invoke(MethodBeforeAdviceInterceptor.java:58)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:173)
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:751)
    at io.seata.spring.annotation.GlobalTransactionalInterceptor$2.execute(GlobalTransactionalInterceptor.java:208)
    at io.seata.tm.api.TransactionalTemplate.execute(TransactionalTemplate.java:128)
    at io.seata.spring.annotation.GlobalTransactionalInterceptor.handleGlobalTransaction(GlobalTransactionalInterceptor.java:205)
    at io.seata.spring.annotation.GlobalTransactionalInterceptor.invoke(GlobalTransactionalInterceptor.java:175)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:184)
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:751)
    at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:97)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:184)
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:751)
    at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:703)
    at com.project.oa.system.controller.SysUserController$$SpringCGLIB$$0.edit(<generated>)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205)
    at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:150)
    at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:118)
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:884)
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:797)
    at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1081)
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:974)
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1014)
    at org.springframework.web.servlet.FrameworkServlet.doPut(FrameworkServlet.java:925)
    at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:550)
    at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:885)
    at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:614)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:205)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149)
    at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149)
    at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149)
    at org.springframework.web.filter.ServerHttpObservationFilter.doFilterInternal(ServerHttpObservationFilter.java:109)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149)
    at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:167)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:90)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:482)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:115)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:93)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:340)
    at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:391)
    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:63)
    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:896)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1744)
    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:52)
    at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
    at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: io.seata.core.exception.RmTransactionException: branch register failed, xid: 10.8.8.29:8091:2648678384710869224, errMsg: TransactionException[branch register request failed. xid=10.8.8.29:8091:2648678384710869224, msg=Duplicate entry 'jdbc:mysql://172.16.1.123:37696/oas^^^sys_user_role^^^10000002_3' for key 'lock_table.PRIMARY'] 
    at io.seata.rm.AbstractResourceManager.branchRegister(AbstractResourceManager.java:70)
    at io.seata.rm.DefaultResourceManager.branchRegister(DefaultResourceManager.java:96)
    at io.seata.rm.datasource.ConnectionProxy.register(ConnectionProxy.java:273)
    at io.seata.rm.datasource.ConnectionProxy.processGlobalTransactionCommit(ConnectionProxy.java:250)
    ... 158 common frames omitted
changeAtLater commented 2 months ago

你可以把异常日志发出来看下吗?因为我看代码在1.5.2应该就已经修复了,server只要是1.5.2以上版本只要遇到唯一索引冲突就会返回false,而不是抛出异常。然后客户端会在第二次竞争锁的时候取消跳过check,然后就会重入锁了 Could you please share the exception log? I see that the code should have been fixed in version 1.5.2. In server versions 1.5.2 and above, encountering a unique index conflict should return false instead of throwing an exception. The client will then skip the check on the second lock attempt and re-enter the lock image

我在方法上加个@Transactional就可以了,原本是有的,我用@GlobalTransactional@Transactional替换掉了,我以为对于本地来说这俩注解没啥区别😓

funky-eyes commented 2 months ago

你可以把异常日志发出来看下吗?因为我看代码在1.5.2应该就已经修复了,server只要是1.5.2以上版本只要遇到唯一索引冲突就会返回false,而不是抛出异常。然后客户端会在第二次竞争锁的时候取消跳过check,然后就会重入锁了 Could you please share the exception log? I see that the code should have been fixed in version 1.5.2. In server versions 1.5.2 and above, encountering a unique index conflict should return false instead of throwing an exception. The client will then skip the check on the second lock attempt and re-enter the lock image

我在方法上加个@Transactional就可以了,原本是有的,我用@GlobalTransactional@Transactional替换掉了,我以为对于本地来说这俩注解没啥区别😓

是的,本地事务注解也可以解决该问题。 Yes, local transaction annotations can also solve this problem.

funky-eyes commented 2 months ago

合并到本地事务是指在更新用户和关联角色的方法上加个@Transactional?

24-09-06 12:23:29.320 [http-nio-9201-exec-4] ERROR i.s.r.d.e.AbstractDMLBaseExecutor - [executeAutoCommitTrue,151] - execute executeAutoCommitTrue error:io.seata.core.exception.RmTransactionException: branch register failed, xid: 10.8.8.29:8091:2648678384710869224, errMsg: TransactionException[branch register request failed. xid=10.8.8.29:8091:2648678384710869224, msg=Duplicate entry 'jdbc:mysql://172.16.1.123:37696/oas^^^sys_user_role^^^10000002_3' for key 'lock_table.PRIMARY'] 
java.sql.SQLException: io.seata.core.exception.RmTransactionException: branch register failed, xid: 10.8.8.29:8091:2648678384710869224, errMsg: TransactionException[branch register request failed. xid=10.8.8.29:8091:2648678384710869224, msg=Duplicate entry 'jdbc:mysql://172.16.1.123:37696/oas^^^sys_user_role^^^10000002_3' for key 'lock_table.PRIMARY'] 
  at io.seata.rm.datasource.ConnectionProxy.recognizeLockKeyConflictException(ConnectionProxy.java:161)
  at io.seata.rm.datasource.ConnectionProxy.processGlobalTransactionCommit(ConnectionProxy.java:252)
  at io.seata.rm.datasource.ConnectionProxy.doCommit(ConnectionProxy.java:230)
  at io.seata.rm.datasource.ConnectionProxy.lambda$commit$0(ConnectionProxy.java:188)
  at io.seata.rm.datasource.ConnectionProxy$LockRetryPolicy.execute(ConnectionProxy.java:344)
  at io.seata.rm.datasource.ConnectionProxy.commit(ConnectionProxy.java:187)
  at io.seata.rm.datasource.exec.AbstractDMLBaseExecutor.lambda$executeAutoCommitTrue$2(AbstractDMLBaseExecutor.java:146)
  at io.seata.rm.datasource.ConnectionProxy$LockRetryPolicy.doRetryOnLockConflict(ConnectionProxy.java:356)
  at io.seata.rm.datasource.exec.AbstractDMLBaseExecutor$LockRetryPolicy.execute(AbstractDMLBaseExecutor.java:188)
  at io.seata.rm.datasource.exec.AbstractDMLBaseExecutor.executeAutoCommitTrue(AbstractDMLBaseExecutor.java:144)
  at io.seata.rm.datasource.exec.AbstractDMLBaseExecutor.doExecute(AbstractDMLBaseExecutor.java:83)
  at io.seata.rm.datasource.exec.BaseTransactionalExecutor.execute(BaseTransactionalExecutor.java:125)
  at io.seata.rm.datasource.exec.ExecuteTemplate.execute(ExecuteTemplate.java:137)
  at io.seata.rm.datasource.exec.ExecuteTemplate.execute(ExecuteTemplate.java:56)
  at io.seata.rm.datasource.PreparedStatementProxy.execute(PreparedStatementProxy.java:55)
  at jdk.internal.reflect.GeneratedMethodAccessor427.invoke(Unknown Source)
  at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.base/java.lang.reflect.Method.invoke(Method.java:568)
  at org.apache.ibatis.logging.jdbc.PreparedStatementLogger.invoke(PreparedStatementLogger.java:58)
  at jdk.proxy3/jdk.proxy3.$Proxy273.execute(Unknown Source)
  at org.apache.ibatis.executor.statement.PreparedStatementHandler.update(PreparedStatementHandler.java:48)
  at org.apache.ibatis.executor.statement.RoutingStatementHandler.update(RoutingStatementHandler.java:75)
  at org.apache.ibatis.executor.SimpleExecutor.doUpdate(SimpleExecutor.java:50)
  at org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:117)
  at org.apache.ibatis.executor.CachingExecutor.update(CachingExecutor.java:76)
  at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
  at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.base/java.lang.reflect.Method.invoke(Method.java:568)
  at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:61)
  at jdk.proxy2/jdk.proxy2.$Proxy271.update(Unknown Source)
  at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:197)
  at org.apache.ibatis.session.defaults.DefaultSqlSession.insert(DefaultSqlSession.java:184)
  at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
  at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.base/java.lang.reflect.Method.invoke(Method.java:568)
  at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:425)
  at jdk.proxy2/jdk.proxy2.$Proxy171.insert(Unknown Source)
  at org.mybatis.spring.SqlSessionTemplate.insert(SqlSessionTemplate.java:272)
  at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:62)
  at org.apache.ibatis.binding.MapperProxy$PlainMethodInvoker.invoke(MapperProxy.java:142)
  at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:86)
  at jdk.proxy2/jdk.proxy2.$Proxy175.batchInsertUserRole(Unknown Source)
  at com.project.oa.system.service.impl.SysUserServiceImpl.insertUserRole(SysUserServiceImpl.java:813)
  at com.project.oa.system.service.impl.SysUserServiceImpl.updateUser(SysUserServiceImpl.java:561)
  at com.project.oa.system.service.impl.SysUserServiceImpl.updateUserInGT(SysUserServiceImpl.java:622)
  at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
  at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.base/java.lang.reflect.Method.invoke(Method.java:568)
  at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:343)
  at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:196)
  at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
  at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:751)
  at io.seata.spring.annotation.GlobalTransactionalInterceptor$2.execute(GlobalTransactionalInterceptor.java:208)
  at io.seata.tm.api.TransactionalTemplate.execute(TransactionalTemplate.java:128)
  at io.seata.spring.annotation.GlobalTransactionalInterceptor.handleGlobalTransaction(GlobalTransactionalInterceptor.java:205)
  at io.seata.spring.annotation.GlobalTransactionalInterceptor.invoke(GlobalTransactionalInterceptor.java:175)
  at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:184)
  at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:751)
  at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:703)
  at com.project.oa.system.service.impl.SysUserServiceImpl$$SpringCGLIB$$0.updateUserInGT(<generated>)
  at com.project.oa.system.service.impl.SysUserServiceImpl.updateUserWithAd(SysUserServiceImpl.java:611)
  at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
  at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.base/java.lang.reflect.Method.invoke(Method.java:568)
  at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:343)
  at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:196)
  at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
  at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:751)
  at io.seata.spring.annotation.GlobalTransactionalInterceptor.invoke(GlobalTransactionalInterceptor.java:181)
  at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:184)
  at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:751)
  at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:703)
  at com.project.oa.system.service.impl.SysUserServiceImpl$$SpringCGLIB$$0.updateUserWithAd(<generated>)
  at com.project.oa.system.controller.SysUserController.edit(SysUserController.java:198)
  at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
  at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.base/java.lang.reflect.Method.invoke(Method.java:568)
  at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:343)
  at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:196)
  at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
  at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:751)
  at org.springframework.aop.aspectj.AspectJAfterThrowingAdvice.invoke(AspectJAfterThrowingAdvice.java:64)
  at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:173)
  at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:751)
  at org.springframework.aop.framework.adapter.AfterReturningAdviceInterceptor.invoke(AfterReturningAdviceInterceptor.java:57)
  at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:173)
  at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:751)
  at org.springframework.aop.framework.adapter.MethodBeforeAdviceInterceptor.invoke(MethodBeforeAdviceInterceptor.java:58)
  at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:173)
  at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:751)
  at io.seata.spring.annotation.GlobalTransactionalInterceptor$2.execute(GlobalTransactionalInterceptor.java:208)
  at io.seata.tm.api.TransactionalTemplate.execute(TransactionalTemplate.java:128)
  at io.seata.spring.annotation.GlobalTransactionalInterceptor.handleGlobalTransaction(GlobalTransactionalInterceptor.java:205)
  at io.seata.spring.annotation.GlobalTransactionalInterceptor.invoke(GlobalTransactionalInterceptor.java:175)
  at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:184)
  at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:751)
  at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:97)
  at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:184)
  at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:751)
  at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:703)
  at com.project.oa.system.controller.SysUserController$$SpringCGLIB$$0.edit(<generated>)
  at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
  at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.base/java.lang.reflect.Method.invoke(Method.java:568)
  at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205)
  at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:150)
  at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:118)
  at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:884)
  at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:797)
  at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
  at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1081)
  at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:974)
  at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1014)
  at org.springframework.web.servlet.FrameworkServlet.doPut(FrameworkServlet.java:925)
  at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:550)
  at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:885)
  at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:614)
  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:205)
  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149)
  at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174)
  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149)
  at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)
  at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116)
  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174)
  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149)
  at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)
  at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116)
  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174)
  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149)
  at org.springframework.web.filter.ServerHttpObservationFilter.doFilterInternal(ServerHttpObservationFilter.java:109)
  at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116)
  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174)
  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149)
  at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
  at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116)
  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174)
  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149)
  at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:167)
  at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:90)
  at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:482)
  at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:115)
  at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:93)
  at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
  at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:340)
  at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:391)
  at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:63)
  at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:896)
  at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1744)
  at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:52)
  at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
  at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
  at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
  at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: io.seata.core.exception.RmTransactionException: branch register failed, xid: 10.8.8.29:8091:2648678384710869224, errMsg: TransactionException[branch register request failed. xid=10.8.8.29:8091:2648678384710869224, msg=Duplicate entry 'jdbc:mysql://172.16.1.123:37696/oas^^^sys_user_role^^^10000002_3' for key 'lock_table.PRIMARY'] 
  at io.seata.rm.AbstractResourceManager.branchRegister(AbstractResourceManager.java:70)
  at io.seata.rm.DefaultResourceManager.branchRegister(DefaultResourceManager.java:96)
  at io.seata.rm.datasource.ConnectionProxy.register(ConnectionProxy.java:273)
  at io.seata.rm.datasource.ConnectionProxy.processGlobalTransactionCommit(ConnectionProxy.java:250)
  ... 158 common frames omitted

需要帮忙提供以下信息, 1.server是否是1.5.2及以上版本? 2.请提供当时服务端的日志

Please provide the following information.

  1. Is the server version 1.5.2 and above?
  2. Please provide the log of the server at that time
changeAtLater commented 2 months ago

合并到本地事务是指在更新用户和关联角色的方法上加个@Transactional?

24-09-06 12:23:29.320 [http-nio-9201-exec-4] ERROR i.s.r.d.e.AbstractDMLBaseExecutor - [executeAutoCommitTrue,151] - execute executeAutoCommitTrue error:io.seata.core.exception.RmTransactionException: branch register failed, xid: 10.8.8.29:8091:2648678384710869224, errMsg: TransactionException[branch register request failed. xid=10.8.8.29:8091:2648678384710869224, msg=Duplicate entry 'jdbc:mysql://172.16.1.123:37696/oas^^^sys_user_role^^^10000002_3' for key 'lock_table.PRIMARY'] 
java.sql.SQLException: io.seata.core.exception.RmTransactionException: branch register failed, xid: 10.8.8.29:8091:2648678384710869224, errMsg: TransactionException[branch register request failed. xid=10.8.8.29:8091:2648678384710869224, msg=Duplicate entry 'jdbc:mysql://172.16.1.123:37696/oas^^^sys_user_role^^^10000002_3' for key 'lock_table.PRIMARY'] 
    at io.seata.rm.datasource.ConnectionProxy.recognizeLockKeyConflictException(ConnectionProxy.java:161)
    at io.seata.rm.datasource.ConnectionProxy.processGlobalTransactionCommit(ConnectionProxy.java:252)
    at io.seata.rm.datasource.ConnectionProxy.doCommit(ConnectionProxy.java:230)
    at io.seata.rm.datasource.ConnectionProxy.lambda$commit$0(ConnectionProxy.java:188)
    at io.seata.rm.datasource.ConnectionProxy$LockRetryPolicy.execute(ConnectionProxy.java:344)
    at io.seata.rm.datasource.ConnectionProxy.commit(ConnectionProxy.java:187)
    at io.seata.rm.datasource.exec.AbstractDMLBaseExecutor.lambda$executeAutoCommitTrue$2(AbstractDMLBaseExecutor.java:146)
    at io.seata.rm.datasource.ConnectionProxy$LockRetryPolicy.doRetryOnLockConflict(ConnectionProxy.java:356)
    at io.seata.rm.datasource.exec.AbstractDMLBaseExecutor$LockRetryPolicy.execute(AbstractDMLBaseExecutor.java:188)
    at io.seata.rm.datasource.exec.AbstractDMLBaseExecutor.executeAutoCommitTrue(AbstractDMLBaseExecutor.java:144)
    at io.seata.rm.datasource.exec.AbstractDMLBaseExecutor.doExecute(AbstractDMLBaseExecutor.java:83)
    at io.seata.rm.datasource.exec.BaseTransactionalExecutor.execute(BaseTransactionalExecutor.java:125)
    at io.seata.rm.datasource.exec.ExecuteTemplate.execute(ExecuteTemplate.java:137)
    at io.seata.rm.datasource.exec.ExecuteTemplate.execute(ExecuteTemplate.java:56)
    at io.seata.rm.datasource.PreparedStatementProxy.execute(PreparedStatementProxy.java:55)
    at jdk.internal.reflect.GeneratedMethodAccessor427.invoke(Unknown Source)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at org.apache.ibatis.logging.jdbc.PreparedStatementLogger.invoke(PreparedStatementLogger.java:58)
    at jdk.proxy3/jdk.proxy3.$Proxy273.execute(Unknown Source)
    at org.apache.ibatis.executor.statement.PreparedStatementHandler.update(PreparedStatementHandler.java:48)
    at org.apache.ibatis.executor.statement.RoutingStatementHandler.update(RoutingStatementHandler.java:75)
    at org.apache.ibatis.executor.SimpleExecutor.doUpdate(SimpleExecutor.java:50)
    at org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:117)
    at org.apache.ibatis.executor.CachingExecutor.update(CachingExecutor.java:76)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:61)
    at jdk.proxy2/jdk.proxy2.$Proxy271.update(Unknown Source)
    at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:197)
    at org.apache.ibatis.session.defaults.DefaultSqlSession.insert(DefaultSqlSession.java:184)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:425)
    at jdk.proxy2/jdk.proxy2.$Proxy171.insert(Unknown Source)
    at org.mybatis.spring.SqlSessionTemplate.insert(SqlSessionTemplate.java:272)
    at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:62)
    at org.apache.ibatis.binding.MapperProxy$PlainMethodInvoker.invoke(MapperProxy.java:142)
    at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:86)
    at jdk.proxy2/jdk.proxy2.$Proxy175.batchInsertUserRole(Unknown Source)
    at com.project.oa.system.service.impl.SysUserServiceImpl.insertUserRole(SysUserServiceImpl.java:813)
    at com.project.oa.system.service.impl.SysUserServiceImpl.updateUser(SysUserServiceImpl.java:561)
    at com.project.oa.system.service.impl.SysUserServiceImpl.updateUserInGT(SysUserServiceImpl.java:622)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:343)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:196)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:751)
    at io.seata.spring.annotation.GlobalTransactionalInterceptor$2.execute(GlobalTransactionalInterceptor.java:208)
    at io.seata.tm.api.TransactionalTemplate.execute(TransactionalTemplate.java:128)
    at io.seata.spring.annotation.GlobalTransactionalInterceptor.handleGlobalTransaction(GlobalTransactionalInterceptor.java:205)
    at io.seata.spring.annotation.GlobalTransactionalInterceptor.invoke(GlobalTransactionalInterceptor.java:175)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:184)
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:751)
    at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:703)
    at com.project.oa.system.service.impl.SysUserServiceImpl$$SpringCGLIB$$0.updateUserInGT(<generated>)
    at com.project.oa.system.service.impl.SysUserServiceImpl.updateUserWithAd(SysUserServiceImpl.java:611)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:343)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:196)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:751)
    at io.seata.spring.annotation.GlobalTransactionalInterceptor.invoke(GlobalTransactionalInterceptor.java:181)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:184)
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:751)
    at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:703)
    at com.project.oa.system.service.impl.SysUserServiceImpl$$SpringCGLIB$$0.updateUserWithAd(<generated>)
    at com.project.oa.system.controller.SysUserController.edit(SysUserController.java:198)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:343)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:196)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:751)
    at org.springframework.aop.aspectj.AspectJAfterThrowingAdvice.invoke(AspectJAfterThrowingAdvice.java:64)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:173)
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:751)
    at org.springframework.aop.framework.adapter.AfterReturningAdviceInterceptor.invoke(AfterReturningAdviceInterceptor.java:57)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:173)
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:751)
    at org.springframework.aop.framework.adapter.MethodBeforeAdviceInterceptor.invoke(MethodBeforeAdviceInterceptor.java:58)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:173)
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:751)
    at io.seata.spring.annotation.GlobalTransactionalInterceptor$2.execute(GlobalTransactionalInterceptor.java:208)
    at io.seata.tm.api.TransactionalTemplate.execute(TransactionalTemplate.java:128)
    at io.seata.spring.annotation.GlobalTransactionalInterceptor.handleGlobalTransaction(GlobalTransactionalInterceptor.java:205)
    at io.seata.spring.annotation.GlobalTransactionalInterceptor.invoke(GlobalTransactionalInterceptor.java:175)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:184)
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:751)
    at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:97)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:184)
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:751)
    at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:703)
    at com.project.oa.system.controller.SysUserController$$SpringCGLIB$$0.edit(<generated>)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205)
    at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:150)
    at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:118)
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:884)
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:797)
    at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1081)
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:974)
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1014)
    at org.springframework.web.servlet.FrameworkServlet.doPut(FrameworkServlet.java:925)
    at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:550)
    at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:885)
    at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:614)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:205)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149)
    at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149)
    at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149)
    at org.springframework.web.filter.ServerHttpObservationFilter.doFilterInternal(ServerHttpObservationFilter.java:109)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149)
    at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:167)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:90)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:482)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:115)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:93)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:340)
    at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:391)
    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:63)
    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:896)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1744)
    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:52)
    at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
    at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: io.seata.core.exception.RmTransactionException: branch register failed, xid: 10.8.8.29:8091:2648678384710869224, errMsg: TransactionException[branch register request failed. xid=10.8.8.29:8091:2648678384710869224, msg=Duplicate entry 'jdbc:mysql://172.16.1.123:37696/oas^^^sys_user_role^^^10000002_3' for key 'lock_table.PRIMARY'] 
    at io.seata.rm.AbstractResourceManager.branchRegister(AbstractResourceManager.java:70)
    at io.seata.rm.DefaultResourceManager.branchRegister(DefaultResourceManager.java:96)
    at io.seata.rm.datasource.ConnectionProxy.register(ConnectionProxy.java:273)
    at io.seata.rm.datasource.ConnectionProxy.processGlobalTransactionCommit(ConnectionProxy.java:250)
    ... 158 common frames omitted

需要帮忙提供以下信息, 1.server是否是1.5.2及以上版本? 2.请提供当时服务端的日志

Please provide the following information.

  1. Is the server version 1.5.2 and above?
  2. Please provide the log of the server at that time

server和client都是1.7.0.

16:28:52.342  INFO --- [     batchLoggerPrint_1_1] [ocessor.server.BatchLogHandler] [                 run]  [] : receive msg[single]: GlobalBeginRequest{transactionName='updateUserInGT(com.project.oa.system.domain.SysUser)', timeout=60000}, clientIp: 10.8.8.29, vgroup: default_tx_group
16:28:52.369  INFO --- [rverHandlerThread_1_3_500] [coordinator.DefaultCoordinator] [       doGlobalBegin]  [10.8.8.29:8091:3657484770757279745] : Begin new global transaction applicationId: oa-system,transactionServiceGroup: default_tx_group, transactionName: updateUserInGT(com.project.oa.system.domain.SysUser),timeout:60000,xid:10.8.8.29:8091:3657484770757279745
16:28:52.371  INFO --- [     batchLoggerPrint_1_1] [ocessor.server.BatchLogHandler] [                 run]  [] : result msg[single]: GlobalBeginResponse{xid='10.8.8.29:8091:3657484770757279745', extraData='null', resultCode=Success, msg='null'}, clientIp: 10.8.8.29, vgroup: default_tx_group
16:28:52.802  INFO --- [     batchLoggerPrint_1_1] [ocessor.server.BatchLogHandler] [                 run]  [] : receive msg[merged]: BranchRegisterRequest{xid='10.8.8.29:8091:3657484770757279745', branchType=AT, resourceId='jdbc:mysql://127.0.0.1:3306/oa', lockKey='sys_user_role:10000002_359262043,10000002_1445610624,10000002_1445610631,10000002_1445610633,10000002_1445610640,10000002_1445610641,10000002_1445610658,10000002_1445610664,10000002_1445610686,10000002_1445610729', applicationData='null'}, clientIp: 10.8.8.29, vgroup: default_tx_group
16:28:53.037  INFO --- [nPool.commonPool-worker-2] [erver.coordinator.AbstractCore] [bda$branchRegister$0]  [10.8.8.29:8091:3657484770757279745] : Register branch successfully, xid = 10.8.8.29:8091:3657484770757279745, branchId = 3657484770757279747, resourceId = jdbc:mysql://127.0.0.1:3306/oa ,lockKeys = sys_user_role:10000002_359262043,10000002_1445610624,10000002_1445610631,10000002_1445610633,10000002_1445610640,10000002_1445610641,10000002_1445610658,10000002_1445610664,10000002_1445610686,10000002_1445610729
16:28:53.038  INFO --- [     batchLoggerPrint_1_1] [ocessor.server.BatchLogHandler] [                 run]  [] : result msg[merged]: BranchRegisterResponse{branchId=3657484770757279747, resultCode=Success, msg='null'}, clientIp: 10.8.8.29, vgroup: default_tx_group
16:28:53.565  INFO --- [     batchLoggerPrint_1_1] [ocessor.server.BatchLogHandler] [                 run]  [] : receive msg[merged]: BranchRegisterRequest{xid='10.8.8.29:8091:3657484770757279745', branchType=AT, resourceId='jdbc:mysql://127.0.0.1:3306/oa', lockKey='sys_user_role:10000002_359262043,10000002_1445610624,10000002_1445610631,10000002_1445610633,10000002_1445610640,10000002_1445610641,10000002_1445610658,10000002_1445610664,10000002_1445610686,10000002_1445610729', applicationData='{"skipCheckLock":true}'}, clientIp: 10.8.8.29, vgroup: default_tx_group
16:28:53.582 ERROR --- [nPool.commonPool-worker-2] [ption.AbstractExceptionHandler] [eptionHandleTemplate]  [10.8.8.29:8091:3657484770757279745] : Catch TransactionException while do RPC, request: BranchRegisterRequest{xid='10.8.8.29:8091:3657484770757279745', branchType=AT, resourceId='jdbc:mysql://127.0.0.1:3306/oa', lockKey='sys_user_role:10000002_359262043,10000002_1445610624,10000002_1445610631,10000002_1445610633,10000002_1445610640,10000002_1445610641,10000002_1445610658,10000002_1445610664,10000002_1445610686,10000002_1445610729', applicationData='{"skipCheckLock":true}'}
==>
io.seata.core.exception.TransactionException: branch register request failed. xid=10.8.8.29:8091:3657484770757279745, msg=Duplicate entry 'jdbc:mysql://127.0.0.1:3306/oa^^^sys_user_role^^^10000002_3' for key 'lock_table.PRIMARY'
        at io.seata.server.AbstractTCInboundHandler$4.execute(AbstractTCInboundHandler.java:187) ~[classes!/:1.7.0]
        at io.seata.server.AbstractTCInboundHandler$4.execute(AbstractTCInboundHandler.java:179) ~[classes!/:1.7.0]
        at io.seata.core.exception.AbstractExceptionHandler.exceptionHandleTemplate(AbstractExceptionHandler.java:131) ~[seata-core-1.7.0.jar:1.7.0]
        at io.seata.server.AbstractTCInboundHandler.handle(AbstractTCInboundHandler.java:179) [classes!/:1.7.0]
        at io.seata.core.protocol.transaction.BranchRegisterRequest.handle(BranchRegisterRequest.java:136) [seata-core-1.7.0.jar:1.7.0]
        at io.seata.server.coordinator.DefaultCoordinator.onRequest(DefaultCoordinator.java:523) [classes!/:1.7.0]
        at io.seata.core.rpc.processor.server.ServerOnRequestProcessor.handleRequestsByMergedWarpMessage(ServerOnRequestProcessor.java:288) [seata-core-1.7.0.jar:1.7.0]
        at io.seata.core.rpc.processor.server.ServerOnRequestProcessor.lambda$onRequestMessage$1(ServerOnRequestProcessor.java:178) [seata-core-1.7.0.jar:1.7.0]
        at java.util.concurrent.CompletableFuture$AsyncSupply.run(Unknown Source) ~[na:1.8.0_231]
        at java.util.concurrent.CompletableFuture$AsyncSupply.exec(Unknown Source) ~[na:1.8.0_231]
        at java.util.concurrent.ForkJoinTask.doExec(Unknown Source) ~[na:1.8.0_231]
        at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(Unknown Source) ~[na:1.8.0_231]
        at java.util.concurrent.ForkJoinPool.runWorker(Unknown Source) ~[na:1.8.0_231]
        at java.util.concurrent.ForkJoinWorkerThread.run(Unknown Source) ~[na:1.8.0_231]
Caused by: io.seata.common.exception.StoreException: Duplicate entry 'jdbc:mysql://127.0.0.1:3306/oa^^^sys_user_role^^^10000002_3' for key 'lock_table.PRIMARY'
        at io.seata.server.storage.db.lock.LockStoreDataBaseDAO.acquireLock(LockStoreDataBaseDAO.java:199) ~[classes!/:1.7.0]
        at io.seata.server.storage.db.lock.DataBaseLocker.acquireLock(DataBaseLocker.java:64) ~[classes!/:1.7.0]
        at io.seata.server.lock.AbstractLockManager.acquireLock(AbstractLockManager.java:65) ~[classes!/:1.7.0]
        at io.seata.server.session.BranchSession.lock(BranchSession.java:287) ~[classes!/:1.7.0]
        at io.seata.server.transaction.at.ATCore.branchSessionLock(ATCore.java:77) ~[classes!/:1.7.0]
        at io.seata.server.coordinator.AbstractCore.lambda$branchRegister$0(AbstractCore.java:83) ~[classes!/:1.7.0]
        at io.seata.server.storage.db.session.DataBaseSessionManager.lockAndExecute(DataBaseSessionManager.java:191) ~[classes!/:1.7.0]
        at io.seata.server.session.SessionHolder.lockAndExecute(SessionHolder.java:367) ~[classes!/:1.7.0]
        at io.seata.server.coordinator.AbstractCore.branchRegister(AbstractCore.java:77) ~[classes!/:1.7.0]
        at io.seata.server.coordinator.DefaultCore.branchRegister(DefaultCore.java:103) ~[classes!/:1.7.0]
        at io.seata.server.coordinator.DefaultCoordinator.doBranchRegister(DefaultCoordinator.java:294) [classes!/:1.7.0]
        at io.seata.server.AbstractTCInboundHandler$4.execute(AbstractTCInboundHandler.java:184) ~[classes!/:1.7.0]
        ... 13 common frames omitted
Caused by: java.sql.BatchUpdateException: Duplicate entry 'jdbc:mysql://127.0.0.1:3306/oa^^^sys_user_role^^^10000002_3' for key 'lock_table.PRIMARY'
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.8.0_231]
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) ~[na:1.8.0_231]
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) ~[na:1.8.0_231]
        at java.lang.reflect.Constructor.newInstance(Unknown Source) ~[na:1.8.0_231]
        at com.mysql.cj.util.Util.handleNewInstance(Util.java:192) ~[mysql-connector-java-8.0.27.jar:8.0.27]
        at com.mysql.cj.util.Util.getInstance(Util.java:167) ~[mysql-connector-java-8.0.27.jar:8.0.27]
        at com.mysql.cj.util.Util.getInstance(Util.java:174) ~[mysql-connector-java-8.0.27.jar:8.0.27]
        at com.mysql.cj.jdbc.exceptions.SQLError.createBatchUpdateException(SQLError.java:224) ~[mysql-connector-java-8.0.27.jar:8.0.27]
        at com.mysql.cj.jdbc.ClientPreparedStatement.executeBatchedInserts(ClientPreparedStatement.java:755) ~[mysql-connector-java-8.0.27.jar:8.0.27]
        at com.mysql.cj.jdbc.ClientPreparedStatement.executeBatchInternal(ClientPreparedStatement.java:426) ~[mysql-connector-java-8.0.27.jar:8.0.27]
        at com.mysql.cj.jdbc.StatementImpl.executeBatch(StatementImpl.java:800) ~[mysql-connector-java-8.0.27.jar:8.0.27]
        at com.alibaba.druid.pool.DruidPooledPreparedStatement.executeBatch(DruidPooledPreparedStatement.java:565) ~[druid-1.2.6.jar:1.2.6]
        at io.seata.server.storage.db.lock.LockStoreDataBaseDAO.doAcquireLocks(LockStoreDataBaseDAO.java:371) ~[classes!/:1.7.0]
        at io.seata.server.storage.db.lock.LockStoreDataBaseDAO.acquireLock(LockStoreDataBaseDAO.java:187) ~[classes!/:1.7.0]
        ... 24 common frames omitted
Caused by: java.sql.SQLIntegrityConstraintViolationException: Duplicate entry 'jdbc:mysql://127.0.0.1:3306/oa^^^sys_user_role^^^10000002_3' for key 'lock_table.PRIMARY'
        at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:117) ~[mysql-connector-java-8.0.27.jar:8.0.27]
        at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122) ~[mysql-connector-java-8.0.27.jar:8.0.27]
        at com.mysql.cj.jdbc.ClientPreparedStatement.executeInternal(ClientPreparedStatement.java:953) ~[mysql-connector-java-8.0.27.jar:8.0.27]
        at com.mysql.cj.jdbc.ClientPreparedStatement.executeUpdateInternal(ClientPreparedStatement.java:1098) ~[mysql-connector-java-8.0.27.jar:8.0.27]
        at com.mysql.cj.jdbc.ClientPreparedStatement.executeUpdateInternal(ClientPreparedStatement.java:1046) ~[mysql-connector-java-8.0.27.jar:8.0.27]
        at com.mysql.cj.jdbc.ClientPreparedStatement.executeLargeUpdate(ClientPreparedStatement.java:1371) ~[mysql-connector-java-8.0.27.jar:8.0.27]
        at com.mysql.cj.jdbc.ClientPreparedStatement.executeBatchedInserts(ClientPreparedStatement.java:716) ~[mysql-connector-java-8.0.27.jar:8.0.27]
        ... 29 common frames omitted
<==

16:28:53.584  INFO --- [     batchLoggerPrint_1_1] [ocessor.server.BatchLogHandler] [                 run]  [] : result msg[merged]: BranchRegisterResponse{branchId=0, resultCode=Failed, msg='TransactionException[branch register request failed. xid=10.8.8.29:8091:3657484770757279745, msg=Duplicate entry 'jdbc:mysql://127.0.0.1:3306/oa^^^sys_user_role^^^10000002_3' for key 'lock_table.PRIMARY']'}, clientIp: 10.8.8.29, vgroup: default_tx_group
16:28:53.645  INFO --- [     batchLoggerPrint_1_1] [ocessor.server.BatchLogHandler] [                 run]  [] : receive msg[single]: GlobalRollbackRequest{xid='10.8.8.29:8091:3657484770757279745', extraData='null'}, clientIp: 10.8.8.29, vgroup: default_tx_group
16:28:53.704  INFO --- [     batchLoggerPrint_1_1] [ocessor.server.BatchLogHandler] [                 run]  [] : receive msg[single]: BranchRollbackResponse{xid='10.8.8.29:8091:3657484770757279745', branchId=3657484770757279747, branchStatus=PhaseTwo_Rollbacked, resultCode=Success, msg='null'}, clientIp: 10.8.8.29, vgroup: default_tx_group
16:28:53.706  INFO --- [rverHandlerThread_1_6_500] [server.coordinator.DefaultCore] [a$doGlobalRollback$3]  [10.8.8.29:8091:3657484770757279745] : Rollback branch transaction successfully, xid = 10.8.8.29:8091:3657484770757279745 branchId = 3657484770757279747
16:28:53.707  INFO --- [rverHandlerThread_1_6_500] [server.coordinator.DefaultCore] [    doGlobalRollback]  [10.8.8.29:8091:3657484770757279745] : Rollback global transaction successfully, xid = 10.8.8.29:8091:3657484770757279745.
16:28:53.710  INFO --- [     batchLoggerPrint_1_1] [ocessor.server.BatchLogHandler] [                 run]  [] : result msg[single]: GlobalRollbackResponse{globalStatus=Rollbacked, resultCode=Success, msg='null'}, clientIp: 10.8.8.29, vgroup: default_tx_group
changeAtLater commented 2 months ago
protected boolean doAcquireLocks(Connection conn, List<LockDO> lockDOs) throws SQLException {
        PreparedStatement ps = null;
        try {
            //insert
            String insertLockSQL = LockStoreSqlFactory.getLogStoreSql(dbType).getInsertLockSQL(lockTable);
            ps = conn.prepareStatement(insertLockSQL);
            for (LockDO lockDO : lockDOs) {
                ps.setString(1, lockDO.getXid());
                ps.setLong(2, lockDO.getTransactionId());
                ps.setLong(3, lockDO.getBranchId());
                ps.setString(4, lockDO.getResourceId());
                ps.setString(5, lockDO.getTableName());
                ps.setString(6, lockDO.getPk());
                ps.setString(7, lockDO.getRowKey());
                ps.setInt(8, lockDO.getStatus());
                ps.addBatch();
            }
            return ps.executeBatch().length == lockDOs.size();
        } catch (SQLIntegrityConstraintViolationException e) {
            LOGGER.error("Global lock batch acquire error: {}", e.getMessage(), e);
            //return false,let the caller go to conn.rollabck()
            return false;
        } catch (SQLException e) {
            throw e;
        } finally {
            IOUtil.close(ps);
        }
    }

return ps.executeBatch().length == lockDOs.size();应该就是这行的改动,导致抛出的异常变了

另外rollback拼错了

funky-eyes commented 2 months ago

我确认是这个问题导致的catch失效了,你可以提个pr帮忙修复这个问题吗? I confirm that this problem caused the catch to fail. Can you provide a PR to help fix this problem?

changeAtLater commented 2 months ago

我确认是这个问题导致的catch失效了,你可以提个pr帮忙修复这个问题吗? I confirm that this problem caused the catch to fail. Can you provide a PR to help fix this problem?

额, 流程是什么?直接fork分支2.x,修改代码后提交合并请求到2.x?

funky-eyes commented 2 months ago

我确认是这个问题导致的catch失效了,你可以提个pr帮忙修复这个问题吗? I confirm that this problem caused the catch to fail. Can you provide a PR to help fix this problem?

额, 流程是什么?直接fork分支2.x,修改代码后提交合并请求到2.x?

是的,尽快跟进下review的留言,这样在2.2上可以合并进去 Yes, follow up the review message ASAP, so that it can be merged on 2.2.