You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by "dyrnq (via GitHub)" <gi...@apache.org> on 2023/11/03 07:44:42 UTC
[I] shardingsphere-jdbc-core 5.4.1 spring boot 2.7.17 READWRITE_SPLITTING not working [shardingsphere]
dyrnq opened a new issue, #28928:
URL: https://github.com/apache/shardingsphere/issues/28928
## 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?
5.4.1
### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
ShardingSphere-JDBC
### Expected behavior
write use ds_1 AND read use ds_2
### Actual behavior
write use ds_1 or ds2 AND read use ds_1 or ds_2
### Reason analyze (If you can)
### Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.
> application.yaml
```bash
server:
port: 8080
spring:
datasource:
driver-class-name: org.apache.shardingsphere.driver.ShardingSphereDriver
url: jdbc:shardingsphere:classpath:xxx.yaml
logging:
level:
root: INFO
mybatis-plus:
configuration:
# MyBatis 配置项,可以根据需要进行配置
cache-enabled: true
map-underscore-to-camel-case: true
# log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
# 其他 MyBatis 配置项...
```
>xxx.yaml
```bash
props:
sql-show: true
sql-simple: false
dataSources:
ds_1:
dataSourceClassName: com.zaxxer.hikari.HikariDataSource
driverClassName: com.mysql.cj.jdbc.Driver
jdbcUrl: jdbc:mysql://192.168.1.130:4406/mydb?useUnicode=true&characterEncoding=utf8&useSSL=false
username: root
password: opening
ds_2:
dataSourceClassName: com.zaxxer.hikari.HikariDataSource
driverClassName: com.mysql.cj.jdbc.Driver
jdbcUrl: jdbc:mysql://192.168.1.130:5506/mydb?useUnicode=true&characterEncoding=utf8&useSSL=false
username: root
password: opening
rules:
- !READWRITE_SPLITTING
dataSources:
readwrite_ds:
writeDataSourceName: ds_1
readDataSourceNames:
- ds_2
transactionalReadQueryStrategy: DYNAMIC
loadBalancerName: random
loadBalancers:
random:
type: ROUND_ROBIN
- !BROADCAST
tables:
- loudong
```
> log
```bash
2023-11-03 15:36:43.951 INFO 486703 --- [ restartedMain] com.example.SQLTest.SqlTestApplication : Started SqlTestApplication in 17.11 seconds (JVM running for 18.503)
2023-11-03 15:37:14.479 INFO 486703 --- [qtp493760912-26] ShardingSphere-SQL : Logic SQL: INSERT INTO loudong ( id,
city,
region,
name,
ld_num,
unit_num ) VALUES ( ?,
?,
?,
?,
?,
? )
2023-11-03 15:37:14.479 INFO 486703 --- [qtp493760912-26] ShardingSphere-SQL : Actual SQL: ds_2 ::: INSERT INTO loudong ( id,
city,
region,
name,
ld_num,
unit_num ) VALUES ( ?,
?,
?,
?,
?,
? ) ::: [2cb4616e-6649-4d56-9, 北京, 通州, ???, 11, 22]
2023-11-03 15:37:14.480 INFO 486703 --- [qtp493760912-26] ShardingSphere-SQL : Actual SQL: ds_1 ::: INSERT INTO loudong ( id,
city,
region,
name,
ld_num,
unit_num ) VALUES ( ?,
?,
?,
?,
?,
? ) ::: [2cb4616e-6649-4d56-9, 北京, 通州, ???, 11, 22]
2023-11-03 15:37:45.663 INFO 486703 --- [qtp493760912-22] ShardingSphere-SQL : Logic SQL: SELECT COUNT(*) FROM loudong
2023-11-03 15:37:45.663 INFO 486703 --- [qtp493760912-22] ShardingSphere-SQL : Actual SQL: ds_1 ::: SELECT COUNT(*) FROM loudong
2023-11-03 15:37:45.885 INFO 486703 --- [qtp493760912-22] ShardingSphere-SQL : Logic SQL: SELECT id,city,region,name,ld_num,unit_num FROM loudong LIMIT ?
2023-11-03 15:37:45.885 INFO 486703 --- [qtp493760912-22] ShardingSphere-SQL : Actual SQL: ds_2 ::: SELECT id,city,region,name,ld_num,unit_num FROM loudong LIMIT ? ::: [10]
```
### Example codes for reproduce this issue (such as a github link).
--
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.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] shardingsphere-jdbc-core 5.4.1 spring boot 2.7.17 READWRITE_SPLITTING not working [shardingsphere]
Posted by "RaigorJiang (via GitHub)" <gi...@apache.org>.
RaigorJiang closed issue #28928: shardingsphere-jdbc-core 5.4.1 spring boot 2.7.17 READWRITE_SPLITTING not working
URL: https://github.com/apache/shardingsphere/issues/28928
--
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
Re: [I] shardingsphere-jdbc-core 5.4.1 spring boot 2.7.17 READWRITE_SPLITTING not working [shardingsphere]
Posted by "dyrnq (via GitHub)" <gi...@apache.org>.
dyrnq commented on issue #28928:
URL: https://github.com/apache/shardingsphere/issues/28928#issuecomment-1800954164
> Hi @dyrnq , Thank you for your feedback, I think it's a bug for broadcast rule.
thanks reply, may be I can use !SINGLE instead of !BROADCAST
```bash
# - !BROADCAST
# tables:
# - loudong
- !SINGLE
tables:
- "*.*"
```
I can not understand !READWRITE_SPLITTING + !BROADCAST mean what?
ref <https://github.com/apache/shardingsphere/issues/28848>
--
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
Re: [I] shardingsphere-jdbc-core 5.4.1 spring boot 2.7.17 READWRITE_SPLITTING not working [shardingsphere]
Posted by "RaigorJiang (via GitHub)" <gi...@apache.org>.
RaigorJiang commented on issue #28928:
URL: https://github.com/apache/shardingsphere/issues/28928#issuecomment-1798170511
Hi @dyrnq ,
Thank you for your feedback, I think it's a bug for broadcast rule.
--
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
Re: [I] shardingsphere-jdbc-core 5.4.1 spring boot 2.7.17 READWRITE_SPLITTING not working [shardingsphere]
Posted by "RaigorJiang (via GitHub)" <gi...@apache.org>.
RaigorJiang commented on issue #28928:
URL: https://github.com/apache/shardingsphere/issues/28928#issuecomment-1807780475
> > Hi @dyrnq , Thank you for your feedback, I think it's a bug for broadcast rule.
>
> thanks reply, may be I can use !SINGLE instead of !BROADCAST
>
> ```shell
> # - !BROADCAST
> # tables:
> # - loudong
> - !SINGLE
> tables:
> - "*.*"
> ```
>
> I can not understand !READWRITE_SPLITTING + !BROADCAST mean what?
>
> ref #28848 AND #28282 AND #28779
If there are multiple groups of READWRITE_SPLITTING RULES, after configuring BROADCAST, write SQL will be routed to the write data source of each group, and a group will be read randomly when reading.
Thanks @jiangML for fixing this issue.
--
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