You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2022/12/08 08:14:52 UTC

[GitHub] [shardingsphere] youngMvcBrother commented on issue #22719: Use auditStrategy to cause duplicate generation keyGenerator

youngMvcBrother commented on issue #22719:
URL: https://github.com/apache/shardingsphere/issues/22719#issuecomment-1342248154

   Hi @RaigorJiang 
   I'm sorry,I reply was a little late. Because ‘mvn clean install ’ takes time.
   **debug result:**
   in the master branch,this issue exists
   
   **My Steps:**
   
   1. 
   
   ```shell
   ## download source code
   git clone https://github.com/apache/shardingsphere.git
   
   ## compile source code
   cd shardingsphere
   mvn clean install -Prelease
   ```
   
   2. 
     add sharding-spring-boot-mybatis-example
   
   3. 
     debug 
   
   **java version**
   
   ```shell
   java version "1.8.0_301"
   Java(TM) SE Runtime Environment (build 1.8.0_301-b09)
   Java HotSpot(TM) 64-Bit Server VM (build 25.301-b09, mixed mode)
   
   ```
   
   **Look**
   ![image](https://user-images.githubusercontent.com/13623260/206390818-8089b1d2-0088-4073-8ed8-586d768c6e09.png)
   ```java
   -------------- Process Success Begin ---------------
   ---------------------------- Insert Data ----------------------------
   [INFO ] 2022-12-08 15:57:18,531 --main-- [ShardingSphere-SQL] Logic SQL: INSERT INTO t_order (user_id, address_id, status) VALUES (?, ?, ?); 
   [INFO ] 2022-12-08 15:57:18,531 --main-- [ShardingSphere-SQL] Actual SQL: ds_1 ::: INSERT INTO t_order_0 (user_id, address_id, status, order_id) VALUES (?, ?, ?, ?); ::: [1, 1, INSERT_TEST, 807641078621536256] 
   [INFO ] 2022-12-08 15:57:18,588 --main-- [ShardingSphere-SQL] Logic SQL: DROP TABLE IF EXISTS t_order; 
   [INFO ] 2022-12-08 15:57:18,588 --main-- [ShardingSphere-SQL] Actual SQL: ds_1 ::: DROP TABLE IF EXISTS t_order_0; 
   [INFO ] 2022-12-08 15:57:18,588 --main-- [ShardingSphere-SQL] Actual SQL: ds_1 ::: DROP TABLE IF EXISTS t_order_1; 
   [INFO ] 2022-12-08 15:57:18,588 --main-- [ShardingSphere-SQL] Actual SQL: ds_0 ::: DROP TABLE IF EXISTS t_order_0; 
   [INFO ] 2022-12-08 15:57:18,588 --main-- [ShardingSphere-SQL] Actual SQL: ds_0 ::: DROP TABLE IF EXISTS t_order_1; 
   [INFO ] 2022-12-08 15:57:18,654 --main-- [ShardingSphere-SQL] Logic SQL: DROP TABLE IF EXISTS t_order_item; 
   [INFO ] 2022-12-08 15:57:18,654 --main-- [ShardingSphere-SQL] Actual SQL: ds_1 ::: DROP TABLE IF EXISTS t_order_item_0; 
   [INFO ] 2022-12-08 15:57:18,654 --main-- [ShardingSphere-SQL] Actual SQL: ds_1 ::: DROP TABLE IF EXISTS t_order_item_1; 
   [INFO ] 2022-12-08 15:57:18,654 --main-- [ShardingSphere-SQL] Actual SQL: ds_0 ::: DROP TABLE IF EXISTS t_order_item_0; 
   [INFO ] 2022-12-08 15:57:18,654 --main-- [ShardingSphere-SQL] Actual SQL: ds_0 ::: DROP TABLE IF EXISTS t_order_item_1; 
   [INFO ] 2022-12-08 15:57:18,712 --main-- [org.quartz.core.QuartzScheduler] Scheduler quartzScheduler_$_NON_CLUSTERED paused. 
   [INFO ] 2022-12-08 15:57:18,713 --main-- [org.springframework.scheduling.quartz.SchedulerFactoryBean] Shutting down Quartz Scheduler 
   [INFO ] 2022-12-08 15:57:18,713 --main-- [org.quartz.core.QuartzScheduler] Scheduler quartzScheduler_$_NON_CLUSTERED shutting down. 
   [INFO ] 2022-12-08 15:57:18,713 --main-- [org.quartz.core.QuartzScheduler] Scheduler quartzScheduler_$_NON_CLUSTERED paused. 
   [INFO ] 2022-12-08 15:57:18,713 --main-- [org.quartz.core.QuartzScheduler] Scheduler quartzScheduler_$_NON_CLUSTERED shutdown complete. 
   [INFO ] 2022-12-08 15:57:18,714 --main-- [com.zaxxer.hikari.HikariDataSource] HikariPool-2 - Shutdown initiated... 
   [INFO ] 2022-12-08 15:57:18,717 --main-- [com.zaxxer.hikari.HikariDataSource] HikariPool-2 - Shutdown completed. 
   [INFO ] 2022-12-08 15:57:18,717 --main-- [com.zaxxer.hikari.HikariDataSource] HikariPool-3 - Shutdown initiated... 
   [INFO ] 2022-12-08 15:57:18,718 --main-- [com.zaxxer.hikari.HikariDataSource] HikariPool-3 - Shutdown completed. 
   [INFO ] 2022-12-08 15:57:18,718 --main-- [com.zaxxer.hikari.HikariDataSource] HikariPool-1 - Shutdown initiated... 
   [INFO ] 2022-12-08 15:57:18,719 --main-- [com.zaxxer.hikari.HikariDataSource] HikariPool-1 - Shutdown completed. 
   Exception in thread "main" org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.executor.ExecutorException: Error getting generated key or setting result to parameter object. Cause: org.apache.ibatis.executor.ExecutorException: Too many keys are generated. There are only 1 target objects. You either specified a wrong 'keyProperty' or encountered a driver bug like #1523.
   	at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:92)
   	at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:440)
   	at com.sun.proxy.$Proxy55.insert(Unknown Source)
   	at org.mybatis.spring.SqlSessionTemplate.insert(SqlSessionTemplate.java:271)
   	at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:62)
   	at org.apache.ibatis.binding.MapperProxy$PlainMethodInvoker.invoke(MapperProxy.java:145)
   	at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:86)
   	at com.sun.proxy.$Proxy56.insert(Unknown Source)
   	at org.apache.shardingsphere.example.core.mybatis.service.OrderServiceImpl.insertData(OrderServiceImpl.java:103)
   	at org.apache.shardingsphere.example.core.mybatis.service.OrderServiceImpl.processSuccess(OrderServiceImpl.java:79)
   	at org.apache.shardingsphere.example.core.mybatis.service.OrderServiceImpl$$FastClassBySpringCGLIB$$bc37129f.invoke(<generated>)
   	at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
   	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:779)
   	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
   	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:750)
   	at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:367)
   	at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:118)
   	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
   	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:750)
   	at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:692)
   	at org.apache.shardingsphere.example.core.mybatis.service.OrderServiceImpl$$EnhancerBySpringCGLIB$$c04768b3.processSuccess(<generated>)
   	at org.apache.shardingsphere.example.core.api.ExampleExecuteTemplate.run(ExampleExecuteTemplate.java:29)
   	at org.apache.shardingsphere.example.sharding.spring.boot.mybatis.ShardingSpringBootMybatisExample.main(ShardingSpringBootMybatisExample.java:38)
   Caused by: org.apache.ibatis.executor.ExecutorException: Error getting generated key or setting result to parameter object. Cause: org.apache.ibatis.executor.ExecutorException: Too many keys are generated. There are only 1 target objects. You either specified a wrong 'keyProperty' or encountered a driver bug like #1523.
   	at org.apache.ibatis.executor.keygen.Jdbc3KeyGenerator.processBatch(Jdbc3KeyGenerator.java:88)
   	at org.apache.ibatis.executor.keygen.Jdbc3KeyGenerator.processAfter(Jdbc3KeyGenerator.java:71)
   	at org.apache.ibatis.executor.statement.PreparedStatementHandler.update(PreparedStatementHandler.java:51)
   	at org.apache.ibatis.executor.statement.RoutingStatementHandler.update(RoutingStatementHandler.java:74)
   	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 org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:194)
   	at org.apache.ibatis.session.defaults.DefaultSqlSession.insert(DefaultSqlSession.java:181)
   	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
   	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   	at java.lang.reflect.Method.invoke(Method.java:498)
   	at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:426)
   	... 21 more
   Caused by: org.apache.ibatis.executor.ExecutorException: Too many keys are generated. There are only 1 target objects. You either specified a wrong 'keyProperty' or encountered a driver bug like #1523.
   	at org.apache.ibatis.executor.keygen.Jdbc3KeyGenerator.assignKeysToParam(Jdbc3KeyGenerator.java:121)
   	at org.apache.ibatis.executor.keygen.Jdbc3KeyGenerator.assignKeys(Jdbc3KeyGenerator.java:104)
   	at org.apache.ibatis.executor.keygen.Jdbc3KeyGenerator.processBatch(Jdbc3KeyGenerator.java:85)
   	... 34 more
   
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org