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 2021/11/30 06:16:28 UTC
[GitHub] [shardingsphere] zjcnb opened a new issue #13860: Use rules not right when I hava two schema with use standalone mode.
zjcnb opened a new issue #13860:
URL: https://github.com/apache/shardingsphere/issues/13860
## Bug Report
**For English only**, other languages will not accept.
Before report a bug, make sure you have:
- Searched open and closed [GitHub issues](https://github.com/apache/shardingsphere/issues).
- Read documentation: [ShardingSphere Doc](https://shardingsphere.apache.org/document/current/en/overview).
Please pay attention on issues you submitted, because we maybe need more details.
If no response anymore and we cannot reproduce it on current information, we will **close it**.
Please answer these questions before submitting your issue. Thanks!
### Which version of ShardingSphere did you use?
master
### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
ShardingSphere-JDBC
### Expected behavior
run successfull
### Actual behavior
```
Exception in thread "main" java.lang.NullPointerException: The props `strategy` cannot be null when uses class based sharding strategy.
at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:987)
at org.apache.shardingsphere.sharding.algorithm.sharding.classbased.ClassBasedShardingAlgorithm.init(ClassBasedShardingAlgorithm.java:62)
at org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmFactory.createAlgorithm(ShardingSphereAlgorithmFactory.java:43)
at org.apache.shardingsphere.sharding.rule.ShardingRule.lambda$new$0(ShardingRule.java:91)
at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684)
at org.apache.shardingsphere.sharding.rule.ShardingRule.<init>(ShardingRule.java:91)
at org.apache.shardingsphere.sharding.rule.builder.ShardingRuleBuilder.build(ShardingRuleBuilder.java:41)
at org.apache.shardingsphere.sharding.rule.builder.ShardingRuleBuilder.build(ShardingRuleBuilder.java:35)
at org.apache.shardingsphere.infra.rule.builder.schema.SchemaRulesBuilder.buildRules(SchemaRulesBuilder.java:85)
at org.apache.shardingsphere.infra.rule.builder.schema.SchemaRulesBuilder.buildRules(SchemaRulesBuilder.java:70)
at org.apache.shardingsphere.mode.manager.standalone.StandaloneContextManagerBuilder.build(StandaloneContextManagerBuilder.java:76)
at org.apache.shardingsphere.driver.jdbc.core.datasource.ShardingSphereDataSource.createContextManager(ShardingSphereDataSource.java:75)
at org.apache.shardingsphere.driver.jdbc.core.datasource.ShardingSphereDataSource.<init>(ShardingSphereDataSource.java:61)
at org.apache.shardingsphere.driver.api.ShardingSphereDataSourceFactory.createDataSource(ShardingSphereDataSourceFactory.java:79)
at org.apache.shardingsphere.driver.api.yaml.YamlShardingSphereDataSourceFactory.createDataSource(YamlShardingSphereDataSourceFactory.java:132)
at org.apache.shardingsphere.driver.api.yaml.YamlShardingSphereDataSourceFactory.createDataSource(YamlShardingSphereDataSourceFactory.java:61)
at org.apache.shardingsphere.example.sharding.raw.jdbc.factory.YamlDataSourceFactory.newInstance(YamlDataSourceFactory.java:33)
at org.apache.shardingsphere.example.sharding.raw.jdbc.ShardingRawYamlConfigurationExample.main(ShardingRawYamlConfigurationExample.java:41)
```
### Reason analyze (If you can)
I have two schemaName, one is multit-tenant, other one is gogogo.
When I use gogogo schemaName, it use multit-tenant rules.
`multit-tenant configuration : `
```
#mybatis:
# type-aliases-package: com.freesun.shardingsphere.multitenancy.model
# type-handlers-package: com.freesun.shardingsphere.multitenancy.dao
# mapper-locations: classpath*:com/freesun/shardingsphere/multitenancy/dao/*.xml
mybatis:
mapper-locations: classpath*:mapper/**/*Mapper.xml
type-aliases-package: com.example
spring:
shardingsphere:
mode:
type: Standalone
repository:
type: File
overwrite: false
schema:
name: multit-tenant
datasource:
names: aliyun,tmall,taobao
aliyun:
type: com.zaxxer.hikari.HikariDataSource
driver-class-name: com.mysql.jdbc.Driver
jdbc-url: jdbc:mysql://127.0.0.1:3306/aliyun?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
username: root
password: 123456
taobao:
type: com.zaxxer.hikari.HikariDataSource
driver-class-name: com.mysql.jdbc.Driver
jdbc-url: jdbc:mysql://127.0.0.1:3306/taobao?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
username: root
password: 123456
tmall:
type: com.zaxxer.hikari.HikariDataSource
driver-class-name: com.mysql.jdbc.Driver
jdbc-url: jdbc:mysql://127.0.0.1:3306/tmall?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
username: root
password: 123456
rules:
sharding:
tables:
ss:
actualDataNodes: tmall.tb_order,taobao.tb_order,aliyun.tb_order
defaultDatabaseStrategy:
standard:
shardingColumn: merchant
shardingAlgorithmName: db-classbased
defaultTableStrategy:
none:
shardingAlgorithms:
db-classbased:
type: CLASS_BASED
props:
strategy: standard
algorithmClassName: com.example.demo.spi.DbShardingAlgorithm
default-sharding-column: merchant
props:
sql-show: true
```
`gogogo configuration : `
```
mode:
type: Standalone
repository:
type: File
overwrite: true
schemaName: gogogo
dataSources:
ds-0:
dataSourceClassName: com.zaxxer.hikari.HikariDataSource
driverClassName: com.mysql.jdbc.Driver
jdbcUrl: jdbc:mysql://localhost:3306/demo_ds_0?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
username: root
password: 123456
ds-1:
dataSourceClassName: com.zaxxer.hikari.HikariDataSource
driverClassName: com.mysql.jdbc.Driver
jdbcUrl: jdbc:mysql://localhost:3306/demo_ds_1?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
username: root
password: 123456
rules:
- !SHARDING
tables:
t_order:
actualDataNodes: ds-${0..1}.t_order
keyGenerateStrategy:
column: order_id
keyGeneratorName: snowflake
t_order_item:
actualDataNodes: ds-${0..1}.t_order_item
keyGenerateStrategy:
column: order_item_id
keyGeneratorName: snowflake
t_account:
actualDataNodes: ds-${0..1}.t_account
keyGenerateStrategy:
column: account_id
keyGeneratorName: snowflake
bindingTables:
- t_order,t_order_item
broadcastTables:
- t_address
defaultDatabaseStrategy:
standard:
shardingColumn: user_id
shardingAlgorithmName: database_inline
defaultTableStrategy:
none:
shardingAlgorithms:
database_inline:
type: INLINE
props:
algorithm-expression: ds-${user_id % 2}
keyGenerators:
snowflake:
type: SNOWFLAKE
props:
worker-id: 123
props:
sql-show: false
```
--
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] tristaZero closed issue #13860: Use rules not right when I hava two schema with use standalone mode.
Posted by GitBox <gi...@apache.org>.
tristaZero closed issue #13860:
URL: https://github.com/apache/shardingsphere/issues/13860
--
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