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 2020/12/09 18:10:02 UTC

[GitHub] [shardingsphere] suikenungleung edited a comment on issue #8514: sharding replica query exception: java.lang.reflect.InvocationTargetException: null

suikenungleung edited a comment on issue #8514:
URL: https://github.com/apache/shardingsphere/issues/8514#issuecomment-741953060


   @tristaZero 
   ```
   ...
   
   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.inline.sharding-column=id
   spring.shardingsphere.rules.sharding.tables.user.table-strategy.inline.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.inline.sharding-column=id
   spring.shardingsphere.rules.sharding.default-database-strategy.inline.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
   ```
   
   Configuration is running normally, But the data is distributed equally to all tables.
   
   Insert 40 data, all tables have been inserted 40 data. This is not correct.
   
   One more question? [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) Configuration  `spring.shardingsphere.rules.sharding.tables.t_order.table-strategy.inline.sharding-colum` This `inline` what is it? I did not see in the configuration item description.
   
   ```
   dataSources: # Omit data source configuration
   rules:
   - !SHARDING
     tables: # Sharding table configuration
       <logic-table-name> (+): # Logic table name
         actualDataNodes (?): # Describe data source names and actual tables, delimiter as point, multiple data nodes separated with comma, support inline expression. Absent means sharding databases only.
         databaseStrategy (?): # Databases sharding strategy, use default databases sharding strategy if absent. sharding strategy below can choose only one.
           standard: # For single sharding column scenario
             shardingColumn: # Sharding column name
             shardingAlgorithmName: # Sharding algorithm name
           complex: # For multiple sharding columns scenario
             shardingColumns: # Sharding column names, multiple columns separated with comma
             shardingAlgorithmName: # Sharding algorithm name
           hint: # Sharding by hint
             shardingAlgorithmName: # Sharding algorithm name
           none: # Do not sharding
         tableStrategy: # Tables sharding strategy, same as database sharding strategy
         keyGenerateStrategy: # Key generator strategy
           column: # Column name of key generator
           keyGeneratorName: # Key generator name
     autoTables: # Auto Sharding table configuration
       t_order_auto: # Logic table name
         actualDataSources (?): # Data source names
         shardingStrategy: # Sharding strategy
           standard: # For single sharding column scenario
             shardingColumn: # Sharding column name
             shardingAlgorithmName: # Auto sharding algorithm name
     bindingTables (+): # Binding tables
       - <logic_table_name_1, logic_table_name_2, ...> 
     broadcastTables (+): # Broadcast tables
       - <table-name>
     defaultDatabaseStrategy: # Default strategy for database sharding
     defaultTableStrategy: # Default strategy for table sharding
     defaultKeyGenerateStrategy: # Default Key generator strategy
   
     # Sharding algorithm configuration
     shardingAlgorithms:
       <sharding-algorithm-name> (+): # Sharding algorithm name
         type: # Sharding algorithm type
         props: # Sharding algorithm properties
         # ...
     
     # Key generate algorithm configuration
     keyGenerators:
       <key-generate-algorithm-name> (+): # Key generate algorithm name
         type: # Key generate algorithm type
         props: # Key generate algorithm properties
         # ...
   
   props:
     # ...
   ```


----------------------------------------------------------------
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:
users@infra.apache.org