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/08/26 14:13:20 UTC

[GitHub] [shardingsphere] Comven opened a new issue #12040: read-write-splitting doesn't work when dismantle the table by month with IntervalShardingAlgorithm

Comven opened a new issue #12040:
URL: https://github.com/apache/shardingsphere/issues/12040


   shardingsphere-jdbc-core-spring-boot-starter-5.0.0-beta
   
   my configuration is like this
   ```
   spring.shardingsphere.props.sql-show=true
   spring.shardingsphere.datasource.names=db1,db1slaver
   
   spring.shardingsphere.datasource.db1.jdbc-url=jdbc:mysql://localhost:3306/sharding_one_master?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&useSSL=false&reconnect=true&serverTimezone=Asia/Shanghai
   spring.shardingsphere.datasource.db1.username=root
   spring.shardingsphere.datasource.db1.password=
   spring.shardingsphere.datasource.db1.type=com.zaxxer.hikari.HikariDataSource
   spring.shardingsphere.datasource.db1.driver-class-name=com.mysql.cj.jdbc.Driver
   
   spring.shardingsphere.datasource.db1slaver.jdbc-url=jdbc:mysql://localhost:3306/sharding_one_slaver?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&useSSL=false&reconnect=true&serverTimezone=Asia/Shanghai
   spring.shardingsphere.datasource.db1slaver.username=root
   spring.shardingsphere.datasource.db1slaver.password=
   spring.shardingsphere.datasource.db1slaver.type=com.zaxxer.hikari.HikariDataSource
   spring.shardingsphere.datasource.db1slaver.driver-class-name=com.mysql.cj.jdbc.Driver
   
   spring.shardingsphere.rules.sharding.tables.order_info.actual-data-nodes=db1.order_info_20$->{21..22}0$->{1..9},db1.order_info_20$->{21..22}$->{10..12}
   spring.shardingsphere.rules.sharding.tables.order_info.table-strategy.standard.shardingColumn=add_time
   spring.shardingsphere.rules.sharding.tables.order_info.table-strategy.standard.shardingAlgorithmName=tbclassbased
   
   # IntervalShardingAlgorithm
   spring.shardingsphere.rules.sharding.sharding-algorithms.tbclassbased.type=interval
   spring.shardingsphere.rules.sharding.sharding-algorithms.tbclassbased.props.datetime-interval-amount=1
   spring.shardingsphere.rules.sharding.sharding-algorithms.tbclassbased.props.datetime-interval-unit=Months
   spring.shardingsphere.rules.sharding.sharding-algorithms.tbclassbased.props.sharding-suffix-pattern=yyyyMM
   spring.shardingsphere.rules.sharding.sharding-algorithms.tbclassbased.props.datetime-pattern=yyyy-MM-dd HH:mm:ss
   spring.shardingsphere.rules.sharding.sharding-algorithms.tbclassbased.props.datetime-lower=2021-06-01 00:00:00
   spring.shardingsphere.rules.sharding.sharding-algorithms.tbclassbased.props.datetime-upper=2021-08-31 23:59:59
   
   spring.shardingsphere.rules.readwrite-splitting.dataSources.dbgroup.writeDataSourceName=db1
   spring.shardingsphere.rules.readwrite-splitting.dataSources.dbgroup.readDataSourceNames=db1slaver
   spring.shardingsphere.rules.readwrite-splitting.dataSources.dbgroup.load-balancer-name=roundRobin
   spring.shardingsphere.rules.readwrite-splitting.load-balancers.roundRobin.type=ROUND_ROBIN
   
   ```
   the `db1` has 7 records, the `db1slaver` has 4 records.
   It doesn't work,executing a query statement always returns 7 records. When I configure it like this
   ```
   spring.shardingsphere.rules.readwrite-splitting.dataSources.db1.writeDataSourceName=db1
   spring.shardingsphere.rules.readwrite-splitting.dataSources.db1.readDataSourceNames=db1slaver
   spring.shardingsphere.rules.readwrite-splitting.dataSources.db1.load-balancer-name=roundRobin
   ```
   `goup1` change to `db1`, it work fine. 
   
   And when I use the Java API to configure it, it also doesn't work unless `goup1` is replaced by `db1`. what's wrong with my code?
   
   The split table execution is normal, and the read-write separation execution fails.
   
   


-- 
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] Comven closed issue #12040: read-write-splitting doesn't work when dismantle the table by month with IntervalShardingAlgorithm

Posted by GitBox <gi...@apache.org>.
Comven closed issue #12040:
URL: https://github.com/apache/shardingsphere/issues/12040


   


-- 
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] Comven commented on issue #12040: read-write-splitting doesn't work when dismantle the table by month with IntervalShardingAlgorithm

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


   > @Comven can you show the correct configuration, please?
   
   If read-write separation is used, the database name in `actual-data-nodes` must be configured as the name of the read-write separation group, such as ` db1 order_ info_ 20$->{21..22}0$->{1..9},db1. order_ info_ 'db1 'in 20 $- > {21.. 22} $- > {10.. 12} ` must be configured as' dbgroup'`
   
   The complete configuration is as follows
   
   ```
   spring.shardingsphere.props.sql-show=true
   spring.shardingsphere.datasource.names=db1master,db1slaver
   
   spring.shardingsphere.datasource.db1master.jdbc-url=jdbc:mysql://localhost:3306/sharding_one_master?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&useSSL=false&reconnect=true&serverTimezone=Asia/Shanghai
   spring.shardingsphere.datasource.db1master.username=root
   spring.shardingsphere.datasource.db1master.password=
   spring.shardingsphere.datasource.db1master.type=com.zaxxer.hikari.HikariDataSource
   spring.shardingsphere.datasource.db1master.driver-class-name=com.mysql.cj.jdbc.Driver
   
   spring.shardingsphere.datasource.db1slaver.jdbc-url=jdbc:mysql://localhost:3306/sharding_one_slaver?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&useSSL=false&reconnect=true&serverTimezone=Asia/Shanghai
   spring.shardingsphere.datasource.db1slaver.username=root
   spring.shardingsphere.datasource.db1slaver.password=
   spring.shardingsphere.datasource.db1slaver.type=com.zaxxer.hikari.HikariDataSource
   spring.shardingsphere.datasource.db1slaver.driver-class-name=com.mysql.cj.jdbc.Driver
   
   spring.shardingsphere.rules.sharding.tables.order_info.actual-data-nodes=dbgroup.order_info_20$->{21..22}0$->{1..9},dbgroup.order_info_20$->{21..22}$->{10..12}
   spring.shardingsphere.rules.sharding.tables.order_info.table-strategy.standard.shardingColumn=add_time
   spring.shardingsphere.rules.sharding.tables.order_info.table-strategy.standard.shardingAlgorithmName=tb-month-sharding
   
   # IntervalShardingAlgorithm
   spring.shardingsphere.rules.sharding.sharding-algorithms.tb-month-sharding.type=interval
   spring.shardingsphere.rules.sharding.sharding-algorithms.tb-month-sharding.props.datetime-interval-amount=1
   spring.shardingsphere.rules.sharding.sharding-algorithms.tb-month-sharding.props.datetime-interval-unit=Months
   spring.shardingsphere.rules.sharding.sharding-algorithms.tb-month-sharding.props.sharding-suffix-pattern=yyyyMM
   spring.shardingsphere.rules.sharding.sharding-algorithms.tb-month-sharding.props.datetime-pattern=yyyy-MM-dd HH:mm:ss
   spring.shardingsphere.rules.sharding.sharding-algorithms.tb-month-sharding.props.datetime-lower=2021-06-01 00:00:00
   spring.shardingsphere.rules.sharding.sharding-algorithms.tb-month-sharding.props.datetime-upper=2021-08-31 23:59:59
   
   spring.shardingsphere.rules.readwrite-splitting.dataSources.dbgroup.writeDataSourceName=db1master
   spring.shardingsphere.rules.readwrite-splitting.dataSources.dbgroup.readDataSourceNames=db1slaver
   ```
   


-- 
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] Comven commented on issue #12040: read-write-splitting doesn't work when dismantle the table by month with IntervalShardingAlgorithm

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


   @avalon5666 Is that what you mean `order_info.actual-data-nodes` should be  configured like `dbgroup.order_info_20$->{21..22}0$->{1..9},dbgroup.order_info_20$->{21..22}$->{10..12}·


-- 
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] Comven edited a comment on issue #12040: read-write-splitting doesn't work when dismantle the table by month with IntervalShardingAlgorithm

Posted by GitBox <gi...@apache.org>.
Comven edited a comment on issue #12040:
URL: https://github.com/apache/shardingsphere/issues/12040#issuecomment-906885504


   @avalon5666 Is that what you mean `order_info.actual-data-nodes` should be  configured like `dbgroup.order_info_20$->{21..22}0$->{1..9},dbgroup.order_info_20$->{21..22}$->{10..12}`


-- 
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] BoBoZhu commented on issue #12040: read-write-splitting doesn't work when dismantle the table by month with IntervalShardingAlgorithm

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


   @Comven can you show the correct configuration, please?


-- 
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] Comven commented on issue #12040: read-write-splitting doesn't work when dismantle the table by month with IntervalShardingAlgorithm

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


   > order_info.actual-data-nodes must use readwrite-splitting data source name.
   
   ok, i see . it's work fine!
   Thank you very much!


-- 
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] avalon5666 commented on issue #12040: read-write-splitting doesn't work when dismantle the table by month with IntervalShardingAlgorithm

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


   order_info.actual-data-nodes must use readwrite-splitting data source name.


-- 
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] Comven commented on issue #12040: read-write-splitting doesn't work when dismantle the table by month with IntervalShardingAlgorithm

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


   @avalon5666 Sorry, I don't understand what you mean. Can you show me how `order_info.actual-data-nodes ` should be configured correctly?


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