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/02/25 08:38:14 UTC
[GitHub] [incubator-shardingsphere] jiangxiewei opened a new issue #4464:
when did the configuration **default-database-strategy** work ?
jiangxiewei opened a new issue #4464: when did the configuration **default-database-strategy** work ?
URL: https://github.com/apache/incubator-shardingsphere/issues/4464
## First of all
my English is suck
## Question
when I only configured the default-database-strategy ( no specific table rule are configured ) , My defaul-database-strategy didn't work. (I use hintManager.setDatabaseShardingValue() )
## Version
4.0.0
## Detail
my configuration as follow :
``` properties
spring.shardingsphere.datasource.names=psghz,psgother
# psghz库配置
spring.shardingsphere.datasource.psghz.url=jdbc:postgresql://*******************:****/*****?useUnicode=true&characterEncoding=UTF-8&useSSL=false
spring.shardingsphere.datasource.psghz.username=****
spring.shardingsphere.datasource.psghz.password=********
spring.shardingsphere.datasource.psghz.driverClassName=org.postgresql.Driver
spring.shardingsphere.datasource.psghz.type=com.alibaba.druid.pool.DruidDataSource
spring.shardingsphere.datasource.psghz.max-active=10
# psgother库配置
spring.shardingsphere.datasource.psgother.url=jdbc:postgresql://*******************:****/*****?useUnicode=true&characterEncoding=UTF-8&useSSL=false
spring.shardingsphere.datasource.psgother.username=****
spring.shardingsphere.datasource.psgother.password=********
spring.shardingsphere.datasource.psgother.driverClassName=org.postgresql.Driver
spring.shardingsphere.datasource.psgother.type=com.alibaba.druid.pool.DruidDataSource
spring.shardingsphere.datasource.psgother.max-active=10
# 默认hint配置
spring.shardingsphere.sharding.default-database-strategy.hint.algorithm-class-name=com.ibuscloud.pubtrans.analysis.plugin.sharding.HintShardingStrategy
#起初打开default-data-srouce-name,结果走了DefaultDatabaseRoutingEngine,关闭则走了UnicastRoutingEngine
#spring.shardingsphere.sharding.default-data-source-name=psghz
spring.shardingsphere.props.sql.show=true
````
I follow the code and see the RoutingEngineFactory.java create UnicastRoutingEngine.java
``` java
if (sqlStatementContext.getSqlStatement() instanceof DMLStatement && tableNames.isEmpty() && shardingRule.hasDefaultDataSourceName()) {
return new DefaultDatabaseRoutingEngine(shardingRule, tableNames);
}
if (sqlStatementContext.getSqlStatement() instanceof DMLStatement && shardingConditions.isAlwaysFalse() || tableNames.isEmpty() || !shardingRule.tableRuleExists(tableNames)) {
return new UnicastRoutingEngine(shardingRule, tableNames);
}
```
and **!shardingRule.tableRuleExists(tableNames)** is true .
so back to the question , how does the default-database-strategy.
----------------------------------------------------------------
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
With regards,
Apache Git Services
[GitHub] [incubator-shardingsphere] wgy8283335 edited a comment on issue
#4464: when did the configuration **default-database-strategy** work ?
Posted by GitBox <gi...@apache.org>.
wgy8283335 edited a comment on issue #4464: when did the configuration **default-database-strategy** work ?
URL: https://github.com/apache/incubator-shardingsphere/issues/4464#issuecomment-591408785
> > OK. I will take care of this issue. You only concern configuration below right?
> > ```
> > spring.shardingsphere.sharding.default-database-strategy.hint.algorithm-class-name=com.ibuscloud.pubtrans.analysis.plugin.sharding.HintShardingStrategy
> > ```
> >
> >
> > @jiangxiewei
>
> yes... emmmm , I use hintManager.setDatabaseShardingValue() to add shardings in hint route to some certain sharding database without sharding tables And I only configured default-database-strategy.hint but it doesn't work like 3.1.0
Sharding-JDBC 4.0 is the software that you are using now, right? @jiangxiewei
----------------------------------------------------------------
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
With regards,
Apache Git Services
[GitHub] [incubator-shardingsphere] jiangxiewei removed a comment on issue
#4464: when did the configuration **default-database-strategy** work ?
Posted by GitBox <gi...@apache.org>.
jiangxiewei removed a comment on issue #4464: when did the configuration **default-database-strategy** work ?
URL: https://github.com/apache/incubator-shardingsphere/issues/4464#issuecomment-591550230
> > > OK. I will take care of this issue. You only concern configuration below right?
> > > ```
> > > spring.shardingsphere.sharding.default-database-strategy.hint.algorithm-class-name=com.ibuscloud.pubtrans.analysis.plugin.sharding.HintShardingStrategy
> > > ```
> > >
> > >
> > > @jiangxiewei
> >
> >
> > yes... emmmm , I use hintManager.setDatabaseShardingValue() to add shardings in hint route to some certain sharding database without sharding tables And I only configured default-database-strategy.hint but it doesn't work like 3.1.0
>
> Sharding-JDBC 4.0 is the software that you are using now, right? @jiangxiewei
no... I used 3.1.0 at first and I try to update the version 4.0.0
----------------------------------------------------------------
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
With regards,
Apache Git Services
[GitHub] [incubator-shardingsphere] jiangxiewei commented on issue #4464:
when did the configuration **default-database-strategy** work ?
Posted by GitBox <gi...@apache.org>.
jiangxiewei commented on issue #4464: when did the configuration **default-database-strategy** work ?
URL: https://github.com/apache/incubator-shardingsphere/issues/4464#issuecomment-591810656
> > > OK. I will take care of this issue. You only concern configuration below right?
> > > ```
> > > spring.shardingsphere.sharding.default-database-strategy.hint.algorithm-class-name=com.ibuscloud.pubtrans.analysis.plugin.sharding.HintShardingStrategy
> > > ```
> > >
> > >
> > > @jiangxiewei
> >
> >
> > yes... emmmm , I use hintManager.setDatabaseShardingValue() to add shardings in hint route to some certain sharding database without sharding tables And I only configured default-database-strategy.hint but it doesn't work like 3.1.0
>
> Sharding-JDBC 4.0 is the software that you are using now, right? @jiangxiewei
yes
----------------------------------------------------------------
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
With regards,
Apache Git Services
[GitHub] [incubator-shardingsphere] jiangxiewei commented on issue #4464:
when did the configuration **default-database-strategy** work ?
Posted by GitBox <gi...@apache.org>.
jiangxiewei commented on issue #4464: when did the configuration **default-database-strategy** work ?
URL: https://github.com/apache/incubator-shardingsphere/issues/4464#issuecomment-590751301
in 3.1.0 ,
when I use hintManager.setDatabaseShardingValue() , ShardingRouterFactory will create DatabaseHintSQLRouter as follow:
```java
public static ShardingRouter newInstance(final ShardingRule shardingRule, final ShardingMetaData shardingMetaData, final DatabaseType databaseType, final boolean showSQL) {
return HintManagerHolder.isDatabaseShardingOnly() ? new DatabaseHintSQLRouter(shardingRule, showSQL) : new ParsingSQLRouter(shardingRule, shardingMetaData, databaseType, showSQL);
}
```
so I rollback to 3.1.0 and the default-database-strategy work well .
----------------------------------------------------------------
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
With regards,
Apache Git Services
[GitHub] [incubator-shardingsphere] jiangxiewei commented on issue #4464:
when did the configuration **default-database-strategy** work ?
Posted by GitBox <gi...@apache.org>.
jiangxiewei commented on issue #4464: when did the configuration **default-database-strategy** work ?
URL: https://github.com/apache/incubator-shardingsphere/issues/4464#issuecomment-591550230
> > > OK. I will take care of this issue. You only concern configuration below right?
> > > ```
> > > spring.shardingsphere.sharding.default-database-strategy.hint.algorithm-class-name=com.ibuscloud.pubtrans.analysis.plugin.sharding.HintShardingStrategy
> > > ```
> > >
> > >
> > > @jiangxiewei
> >
> >
> > yes... emmmm , I use hintManager.setDatabaseShardingValue() to add shardings in hint route to some certain sharding database without sharding tables And I only configured default-database-strategy.hint but it doesn't work like 3.1.0
>
> Sharding-JDBC 4.0 is the software that you are using now, right? @jiangxiewei
no... I used 3.1.0 at first and I try to update the version 4.0.0
----------------------------------------------------------------
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
With regards,
Apache Git Services
[GitHub] [incubator-shardingsphere] wgy8283335 commented on issue #4464:
when did the configuration **default-database-strategy** work ?
Posted by GitBox <gi...@apache.org>.
wgy8283335 commented on issue #4464: when did the configuration **default-database-strategy** work ?
URL: https://github.com/apache/incubator-shardingsphere/issues/4464#issuecomment-592391509
@jiangxiewei Hi, I find that a similar issue #3964. And the bug is fixed in 5.0.0 version.
----------------------------------------------------------------
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
With regards,
Apache Git Services
[GitHub] [incubator-shardingsphere] kimmking commented on issue #4464: when
did the configuration **default-database-strategy** work ?
Posted by GitBox <gi...@apache.org>.
kimmking commented on issue #4464: when did the configuration **default-database-strategy** work ?
URL: https://github.com/apache/incubator-shardingsphere/issues/4464#issuecomment-591372329
I think it's duplicated with https://github.com/apache/incubator-shardingsphere/issues/4478
----------------------------------------------------------------
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
With regards,
Apache Git Services
[GitHub] [incubator-shardingsphere] jiangxiewei edited a comment on issue
#4464: when did the configuration **default-database-strategy** work ?
Posted by GitBox <gi...@apache.org>.
jiangxiewei edited a comment on issue #4464: when did the configuration **default-database-strategy** work ?
URL: https://github.com/apache/incubator-shardingsphere/issues/4464#issuecomment-590751301
in 3.1.0 ,
when I use hintManager.setDatabaseShardingValue() , ShardingRouterFactory will create DatabaseHintSQLRouter(deleted in 4.0.0) as follow:
```java
public static ShardingRouter newInstance(final ShardingRule shardingRule, final ShardingMetaData shardingMetaData, final DatabaseType databaseType, final boolean showSQL) {
return HintManagerHolder.isDatabaseShardingOnly() ? new DatabaseHintSQLRouter(shardingRule, showSQL) : new ParsingSQLRouter(shardingRule, shardingMetaData, databaseType, showSQL);
}
```
so I rollback to 3.1.0 and the default-database-strategy work well .
----------------------------------------------------------------
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
With regards,
Apache Git Services
[GitHub] [incubator-shardingsphere] wgy8283335 commented on issue #4464:
when did the configuration **default-database-strategy** work ?
Posted by GitBox <gi...@apache.org>.
wgy8283335 commented on issue #4464: when did the configuration **default-database-strategy** work ?
URL: https://github.com/apache/incubator-shardingsphere/issues/4464#issuecomment-590891004
OK. I will take care of this issue. You only concern configuration below right?
```
spring.shardingsphere.sharding.default-database-strategy.hint.algorithm-class-name=com.ibuscloud.pubtrans.analysis.plugin.sharding.HintShardingStrategy
```
----------------------------------------------------------------
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
With regards,
Apache Git Services
[GitHub] [incubator-shardingsphere] jiangxiewei commented on issue #4464:
when did the configuration **default-database-strategy** work ?
Posted by GitBox <gi...@apache.org>.
jiangxiewei commented on issue #4464: when did the configuration **default-database-strategy** work ?
URL: https://github.com/apache/incubator-shardingsphere/issues/4464#issuecomment-591001068
> OK. I will take care of this issue. You only concern configuration below right?
>
> ```
> spring.shardingsphere.sharding.default-database-strategy.hint.algorithm-class-name=com.ibuscloud.pubtrans.analysis.plugin.sharding.HintShardingStrategy
> ```
>
> @jiangxiewei
yes... emmmm , I use hintManager.setDatabaseShardingValue() to add shardings in hint route to some certain sharding database without sharding tables And I only configured default-database-strategy.hint but it doesn't work like 3.1.0
----------------------------------------------------------------
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
With regards,
Apache Git Services
[GitHub] [incubator-shardingsphere] wgy8283335 edited a comment on issue
#4464: when did the configuration **default-database-strategy** work ?
Posted by GitBox <gi...@apache.org>.
wgy8283335 edited a comment on issue #4464: when did the configuration **default-database-strategy** work ?
URL: https://github.com/apache/incubator-shardingsphere/issues/4464#issuecomment-590891004
OK. I will take care of this issue. You only concern configuration below right?
```
spring.shardingsphere.sharding.default-database-strategy.hint.algorithm-class-name=com.ibuscloud.pubtrans.analysis.plugin.sharding.HintShardingStrategy
```
@jiangxiewei
----------------------------------------------------------------
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
With regards,
Apache Git Services
[GitHub] [incubator-shardingsphere] wgy8283335 commented on issue #4464:
when did the configuration **default-database-strategy** work ?
Posted by GitBox <gi...@apache.org>.
wgy8283335 commented on issue #4464: when did the configuration **default-database-strategy** work ?
URL: https://github.com/apache/incubator-shardingsphere/issues/4464#issuecomment-591408785
> > OK. I will take care of this issue. You only concern configuration below right?
> > ```
> > spring.shardingsphere.sharding.default-database-strategy.hint.algorithm-class-name=com.ibuscloud.pubtrans.analysis.plugin.sharding.HintShardingStrategy
> > ```
> >
> >
> > @jiangxiewei
>
> yes... emmmm , I use hintManager.setDatabaseShardingValue() to add shardings in hint route to some certain sharding database without sharding tables And I only configured default-database-strategy.hint but it doesn't work like 3.1.0
Sharding-JDBC 4.0 is the software that you are using now, right?
----------------------------------------------------------------
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
With regards,
Apache Git Services
[GitHub] [incubator-shardingsphere] wgy8283335 closed issue #4464: when did
the configuration **default-database-strategy** work ?
Posted by GitBox <gi...@apache.org>.
wgy8283335 closed issue #4464: when did the configuration **default-database-strategy** work ?
URL: https://github.com/apache/incubator-shardingsphere/issues/4464
----------------------------------------------------------------
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
With regards,
Apache Git Services