suikenungleung opened a new issue #8514: URL: https://github.com/apache/shardingsphere/issues/8514
Spring Boot: 2.3.6 ShardingSphere-JDBC:5.0.0-alph The configuration is as follows: Refer to the official example: [application-sharding-replica-query.properties](https://github.com/apache/shardingsphere/blob/master/examples/shardingsphere-jdbc-example/sharding-example/sharding-spring-boot-mybatis-example/src/main/resources/application-sharding-replica-query.properties) Example 1 ``` spring.shardingsphere.datasource.names=ds-p0,ds-p0-r0,ds-p0-r1,ds-p1,ds-p1-r0,ds-p1-r1 spring.shardingsphere.datasource.common.type=com.zaxxer.hikari.HikariDataSource spring.shardingsphere.datasource.common.driver-class-name=com.mysql.cj.jdbc.Driver spring.shardingsphere.datasource.common.username=root spring.shardingsphere.datasource.common.password=123456 spring.shardingsphere.datasource.ds-p0.jdbc-url=jdbc:mysql://192.168.177.135:3306/sugus?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8 spring.shardingsphere.datasource.ds-p0-r0.jdbc-url=jdbc:mysql://192.168.177.135:3307/sugus?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8 spring.shardingsphere.datasource.ds-p0-r1.jdbc-url=jdbc:mysql://192.168.177.135:3308/sugus?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8 spring.shardingsphere.datasource.ds-p1.jdbc-url=jdbc:mysql://192.168.177.135:3310/sugus?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8 spring.shardingsphere.datasource.ds-p1-r0.jdbc-url=jdbc:mysql://192.168.177.135:3311/sugus?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8 spring.shardingsphere.datasource.ds-p1-r1.jdbc-url=jdbc:mysql://192.168.177.135:3312/sugus?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8 spring.shardingsphere.rules.sharding.tables.user.actual-data-nodes=ds-$->{0..1}.user_$->{0..2} spring.shardingsphere.rules.sharding.binding-tables=user spring.shardingsphere.rules.sharding.broadcast-tables=address spring.shardingsphere.rules.sharding.tables.user.key-generate-strategy.column=id spring.shardingsphere.rules.sharding.tables.user.key-generate-strategy.key-generator-name=snowflake spring.shardingsphere.rules.sharding.tables.user.table-strategy.standard.sharding-column=id spring.shardingsphere.rules.sharding.tables.user.table-strategy.standard.sharding-algorithm-name=user-inline spring.shardingsphere.rules.sharding.tables.user.table-strategy.inline.sharding-column=id spring.shardingsphere.rules.sharding.tables.user.table-strategy.inline.algorithm-expression=user_$->{id % 3} spring.shardingsphere.rules.sharding.default-database-strategy.inline.sharding-column=id spring.shardingsphere.rules.sharding.default-database-strategy.inline.algorithm-expression=ds-$->{id % 2} spring.shardingsphere.rules.sharding.key-generators.snowflake.type=SNOWFLAKE spring.shardingsphere.rules.sharding.key-generators.snowflake.props.worker-id=123 spring.shardingsphere.rules.replica-query.load-balancers.robin-0.type=ROUND_ROBIN spring.shardingsphere.rules.replica-query.load-balancers.robin-0.props.sql-show=true spring.shardingsphere.rules.replica-query.data-sources.ds-0.primary-data-source-name=ds-p0 spring.shardingsphere.rules.replica-query.data-sources.ds-0.replica-data-source-names=ds-p0-r0,ds-p0-r1 spring.shardingsphere.rules.replica-query.data-sources.ds-0.load-balancer-name=robin-0 spring.shardingsphere.rules.replica-query.load-balancers.robin-1.type=ROUND_ROBIN spring.shardingsphere.rules.replica-query.load-balancers.robin-1.props.sql-show=true spring.shardingsphere.rules.replica-query.data-sources.ds-1.primary-data-source-name=ds-p1 spring.shardingsphere.rules.replica-query.data-sources.ds-1.replica-data-source-names=ds-p1-r0,ds-p1-r1 spring.shardingsphere.rules.replica-query.data-sources.ds-1.load-balancer-name=robin-1 ``` Runtime error: java.lang.reflect.InvocationTargetException: null. Example 2 ``` spring.shardingsphere.datasource.names=ds-p0,ds-p0-r0,ds-p0-r1,ds-p1,ds-p1-r0,ds-p1-r1 spring.shardingsphere.datasource.common.type=com.zaxxer.hikari.HikariDataSource spring.shardingsphere.datasource.common.driver-class-name=com.mysql.cj.jdbc.Driver spring.shardingsphere.datasource.common.username=root spring.shardingsphere.datasource.common.password=123456 spring.shardingsphere.datasource.ds-p0.jdbc-url=jdbc:mysql://192.168.177.135:3306/sugus?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8 spring.shardingsphere.datasource.ds-p0-r0.jdbc-url=jdbc:mysql://192.168.177.135:3307/sugus?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8 spring.shardingsphere.datasource.ds-p0-r1.jdbc-url=jdbc:mysql://192.168.177.135:3308/sugus?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8 spring.shardingsphere.datasource.ds-p1.jdbc-url=jdbc:mysql://192.168.177.135:3310/sugus?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8 spring.shardingsphere.datasource.ds-p1-r0.jdbc-url=jdbc:mysql://192.168.177.135:3311/sugus?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8 spring.shardingsphere.datasource.ds-p1-r1.jdbc-url=jdbc:mysql://192.168.177.135:3312/sugus?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8 spring.shardingsphere.rules.sharding.tables.user.actual-data-nodes=ds-$->{0..1}.user_$->{0..2} spring.shardingsphere.rules.sharding.binding-tables=user #spring.shardingsphere.rules.sharding.broadcast-tables=address spring.shardingsphere.rules.sharding.tables.user.key-generate-strategy.column=id spring.shardingsphere.rules.sharding.tables.user.key-generate-strategy.key-generator-name=snowflake spring.shardingsphere.rules.sharding.tables.user.table-strategy.standard.sharding-column=id spring.shardingsphere.rules.sharding.tables.user.table-strategy.standard.sharding-algorithm-name=user-inline spring.shardingsphere.rules.sharding.sharding-algorithms.user-inline.type=INLINE spring.shardingsphere.rules.sharding.sharding-algorithms.user-inline.props.algorithm-expression=user_$->{id % 3} spring.shardingsphere.rules.sharding.default-database-strategy.standard.sharding-column=id spring.shardingsphere.rules.sharding.default-database-strategy.standard.sharding-algorithm-name=database-inline spring.shardingsphere.rules.sharding.sharding-algorithms.database-inline.type=INLINE spring.shardingsphere.rules.sharding.sharding-algorithms.database-inline.props.algorithm-expression=ds-$->{id % 2} spring.shardingsphere.rules.sharding.key-generators.snowflake.type=SNOWFLAKE spring.shardingsphere.rules.sharding.key-generators.snowflake.props.worker-id=123 spring.shardingsphere.rules.replica-query.load-balancers.robin-0.type=ROUND_ROBIN spring.shardingsphere.rules.replica-query.load-balancers.robin-0.props.sql-show=true spring.shardingsphere.rules.replica-query.data-sources.ds-0.primary-data-source-name=ds-p0 spring.shardingsphere.rules.replica-query.data-sources.ds-0.replica-data-source-names=ds-p0-r0,ds-p0-r1 spring.shardingsphere.rules.replica-query.data-sources.ds-0.load-balancer-name=robin-0 spring.shardingsphere.rules.replica-query.load-balancers.robin-1.type=ROUND_ROBIN spring.shardingsphere.rules.replica-query.load-balancers.robin-1.props.sql-show=true spring.shardingsphere.rules.replica-query.data-sources.ds-1.primary-data-source-name=ds-p1 spring.shardingsphere.rules.replica-query.data-sources.ds-1.replica-data-source-names=ds-p1-r0,ds-p1-r1 spring.shardingsphere.rules.replica-query.data-sources.ds-1.load-balancer-name=robin-1 ``` Example 2 combined: [application-replica-query.properties](https://github.com/apache/shardingsphere/blob/master/examples/shardingsphere-jdbc-example/sharding-example/sharding-spring-boot-mybatis-example/src/main/resources/application-replica-query.properties) and [application-sharding-databases-tables.properties](https://github.com/apache/shardingsphere/blob/master/examples/shardingsphere-jdbc-example/sharding-example/sharding-spring-boot-mybatis-example/src/main/resources/application-sharding-databases-tables.properties) operating normally and read and write normally. Two questions: 1. Example 1 why wrong. 2. Example 2 is there any hidden danger in this configuration. ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: [email protected]
