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/05/25 06:24:37 UTC

[GitHub] [shardingsphere] chenwenhua666 opened a new issue, #17930: shardingsphere5.1.1 broadcast-tables error:

chenwenhua666 opened a new issue, #17930:
URL: https://github.com/apache/shardingsphere/issues/17930

   ## Question
   springboot version: 2.3.12.RELEASE
   mybatis-plus.version:3.5.1
   mybatis-plus.dynamic.version:3.3.6
   sharding-shardingsphere.version:5.1.1
   ## yml
   spring:
     batch:
       job:
         enabled: true
     autoconfigure:
       exclude: com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure
     datasource:
       dynamic:
         druid:
           initial-size: 5
           max-active: 20
           min-idle: 5
           max-wait: 60000
           validation-query: select 1
           validation-query-timeout: 2000
           test-on-borrow: false
           test-on-return: false
           test-while-idle: true
           time-between-eviction-runs-millis: 60000
           min-evictable-idle-time-millis: 300000
           stat:
             log-slow-sql: true
             merge-sql: true
             slow-sql-millis: 10000
         primary: master
         datasource:
           master:
             driver-class-name: com.mysql.cj.jdbc.Driver
             url: jdbc:mysql://127.0.0.1:3306/springbatch
             username: root
             password: 123456
           slave1:
             driver-class-name: com.mysql.cj.jdbc.Driver
             url: jdbc:mysql://127.0.0.1:3306/springbatch1
             username: root
             password: 123456
           slave2:
             driver-class-name: com.mysql.cj.jdbc.Driver
             url: jdbc:mysql://127.0.0.1:3306/springbatch2
             username: root
             password: 123456
   
     shardingsphere:
       mode:
         type: Memory
       props:
         sql-show: true
       datasource:
         names: ds1,ds2
         ds1:
           type: com.alibaba.druid.pool.DruidDataSource
           driver-class-name: com.mysql.cj.jdbc.Driver
           url: jdbc:mysql://127.0.0.1:3306/springbatch1
           username: root
           password: 123456
         ds2:
           type: com.alibaba.druid.pool.DruidDataSource
           driver-class-name: com.mysql.cj.jdbc.Driver
           url: jdbc:mysql://127.0.0.1:3306/springbatch2
           username: root
           password: 123456
       rules:
         sharding:
           tables:
             t_order:
               actual-data-nodes: ds$->{1..2}.t_order_$->{1..2}
               key-generate-strategy:
                 column: order_id
                 key-generator-name: leaf-segment
               database-strategy:
                 standard:
                   sharding-column: user_id
                   sharding-algorithm-name: database-t-order-inline
               table-strategy:
                 standard:
                   sharding-column: order_id
                   sharding-algorithm-name: table-t-order-inline
           sharding-algorithms:
             database-t-order-inline:
               type: INLINE
               props:
                 algorithm-expression: ds$->{user_id % 2 + 1}
             table-t-order-inline:
               type: INLINE
               props:
                 algorithm-expression: t_order_$->{order_id % 2 + 1}
                 allow-range-query-with-inline-sharding: true
           key-generators:
             leaf-segment:
               type: leafSegment
               props:
                 biz-tag: leaf-segment-test
             leaf-snowflake:
               type: leafSnowflake
   
           broadcast-tables: t_dict
   
   ## entity
   @Data
   @TableName("t_dict")
   public class Dict implements Serializable {
   	private static final long serialVersionUID = 1L;
   	@JsonSerialize(using = ToStringSerializer.class)
   	@TableId(value = "id", type = IdType.AUTO)
   	private Long id;
   	@JsonSerialize(using = ToStringSerializer.class)
   	private Long parentId;
   	private String code;
   	private String dictKey;
   	private String dictValue;
   	private Integer sort;
   	private String remark;
   	@TableLogic
   	private Integer isDeleted;
   }
   
   ## mysql table
   CREATE TABLE `t_dict` (
     `id` bigint(64) NOT NULL AUTO_INCREMENT ,
     `parent_id` bigint(64) DEFAULT '0',
     `code` varchar(255) DEFAULT NULL,
     `dict_key` varchar(255) DEFAULT NULL,
     `dict_value` varchar(255) DEFAULT NULL,
     `sort` int(11) DEFAULT NULL,
     `remark` varchar(255) DEFAULT NULL,
     `is_deleted` int(2) DEFAULT '0',
     PRIMARY KEY (`id`) USING BTREE
   ) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8mb4;
   
   ## test insert
   
   @Test
       public void testInsertDict() {
           Dict dict = new Dict();
           dict.setCode("user_type");
           dict.setDictKey("-1");
           dict.setDictValue("用户类型");
           dict.setSort(1);
           dictService.save(dict);
           Long parentId = dict.getId();
           Dict dict2 = new Dict();
           dict2.setParentId(parentId);
           dict2.setCode("user_type");
           dict2.setDictKey("1");
           dict2.setDictValue("app");
           dict2.setSort(1);
           dictService.save(dict2);
           Dict dict3 = new Dict();
           dict3.setParentId(parentId);
           dict3.setCode("user_type");
           dict3.setDictKey("2");
           dict3.setDictValue("web");
           dict3.setSort(2);
           dictService.save(dict3);
       }
   
   ## error
   
   2022-05-25 14:05:39.613 DEBUG 5848 --- [           main] c.b.d.d.DynamicRoutingDataSource         : dynamic-datasource switch to the datasource named [shardingSphere]
   2022-05-25 14:05:40.849  INFO 5848 --- [           main] ShardingSphere-SQL                       : Logic SQL: INSERT INTO t_dict  ( code,
   dict_key,
   dict_value,
   sort )  VALUES  ( ?,
   ?,
   ?,
   ? )
   2022-05-25 14:05:40.849  INFO 5848 --- [           main] ShardingSphere-SQL                       : SQLStatement: MySQLInsertStatement(setAssignment=Optional.empty, onDuplicateKeyColumns=Optional.empty)
   2022-05-25 14:05:40.849  INFO 5848 --- [           main] ShardingSphere-SQL                       : Actual SQL: ds1 ::: INSERT INTO t_dict  ( code,
   dict_key,
   dict_value,
   sort )  VALUES  (?, ?, ?, ?) ::: [user_type, -1, 用户类型, 1]
   2022-05-25 14:05:40.849  INFO 5848 --- [           main] ShardingSphere-SQL                       : Actual SQL: ds2 ::: INSERT INTO t_dict  ( code,
   dict_key,
   dict_value,
   sort )  VALUES  (?, ?, ?, ?) ::: [user_type, -1, 用户类型, 1]
   
   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:96)
   	at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:441)
   	at com.sun.proxy.$Proxy104.insert(Unknown Source)
   	at org.mybatis.spring.SqlSessionTemplate.insert(SqlSessionTemplate.java:272)
   	at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.execute(MybatisMapperMethod.java:59)
   	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.$Proxy107.insert(Unknown Source)
   	at com.baomidou.mybatisplus.extension.service.IService.save(IService.java:63)
   	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:779)
   	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
   	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:750)
   	at com.baomidou.dynamic.datasource.aop.DynamicDataSourceAnnotationInterceptor.invoke(DynamicDataSourceAnnotationInterceptor.java:50)
   	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 com.plm.platform.batch.service.impl.DictServiceImpl$$EnhancerBySpringCGLIB$$ecc432ea.save(<generated>)
   	at com.plm.platform.PlatformApplicationTests.testInsertDict(PlatformApplicationTests.java:121)
   	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.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:686)
   	at org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60)
   	at org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed(InvocationInterceptorChain.java:131)
   	at org.junit.jupiter.engine.extension.TimeoutExtension.intercept(TimeoutExtension.java:149)
   	at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestableMethod(TimeoutExtension.java:140)
   	at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestMethod(TimeoutExtension.java:84)
   	at org.junit.jupiter.engine.execution.ExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0(ExecutableInvoker.java:115)
   	at org.junit.jupiter.engine.execution.ExecutableInvoker.lambda$invoke$0(ExecutableInvoker.java:105)
   	at org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:106)
   	at org.junit.jupiter.engine.execution.InvocationInterceptorChain.proceed(InvocationInterceptorChain.java:64)
   	at org.junit.jupiter.engine.execution.InvocationInterceptorChain.chainAndInvoke(InvocationInterceptorChain.java:45)
   	at org.junit.jupiter.engine.execution.InvocationInterceptorChain.invoke(InvocationInterceptorChain.java:37)
   	at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:104)
   	at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:98)
   	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeTestMethod$6(TestMethodTestDescriptor.java:212)
   	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
   	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeTestMethod(TestMethodTestDescriptor.java:208)
   	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:137)
   	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:71)
   	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:135)
   	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
   	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125)
   	at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135)
   	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123)
   	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
   	at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122)
   	at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80)
   	at java.util.ArrayList.forEach(ArrayList.java:1257)
   	at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38)
   	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139)
   	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
   	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125)
   	at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135)
   	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123)
   	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
   	at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122)
   	at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80)
   	at java.util.ArrayList.forEach(ArrayList.java:1257)
   	at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38)
   	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139)
   	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
   	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125)
   	at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135)
   	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123)
   	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
   	at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122)
   	at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80)
   	at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:32)
   	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
   	at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:51)
   	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:248)
   	at org.junit.platform.launcher.core.DefaultLauncher.lambda$execute$5(DefaultLauncher.java:211)
   	at org.junit.platform.launcher.core.DefaultLauncher.withInterceptedStreams(DefaultLauncher.java:226)
   	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:199)
   	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:132)
   	at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:74)
   	at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
   	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
   	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
   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 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.apache.ibatis.plugin.Plugin.invoke(Plugin.java:64)
   	at com.sun.proxy.$Proxy292.update(Unknown Source)
   	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 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.apache.ibatis.plugin.Invocation.proceed(Invocation.java:49)
   	at com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor.intercept(MybatisPlusInterceptor.java:106)
   	at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:62)
   	at com.sun.proxy.$Proxy291.update(Unknown Source)
   	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:427)
   	... 81 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)
   	... 108 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.apache.org

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


[GitHub] [shardingsphere] terrymanu commented on issue #17930: shardingsphere5.1.1 broadcast-tables error:

Posted by GitBox <gi...@apache.org>.
terrymanu commented on issue #17930:
URL: https://github.com/apache/shardingsphere/issues/17930#issuecomment-1159481317

   The exception is not thrown from ShardingSphere, could you take a look with the integrate frameworks?


-- 
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


[GitHub] [shardingsphere] terrymanu closed issue #17930: shardingsphere5.1.1 broadcast-tables error:

Posted by GitBox <gi...@apache.org>.
terrymanu closed issue #17930: shardingsphere5.1.1 broadcast-tables error: 
URL: https://github.com/apache/shardingsphere/issues/17930


-- 
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