huhusu opened a new issue, #32359:
URL: https://github.com/apache/shardingsphere/issues/32359
## Bug Report
### Which version of ShardingSphere did you use?
5.4.0/5.4.1
### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
ShardingSphere-JDBC
Description:
have 4 datasource,two write ds and two read ds
### Expected behavior
When executing an SQL query, should use datasoure slave0 or slave1
### Actual behavior
When executing an SQL query, the datasource master0 or master1 was actually
used
The log is shown below:
```
2024-08-01 18:48:25.595|main|INFO||||10912|ShardingSphere-SQL|MSG=Logic SQL:
SELECT user_id,name,sex FROM tb_newinfo
WHERE user_id=?
2024-08-01 18:48:25.595|main|INFO||||10912|ShardingSphere-SQL|MSG=ACTUAL
SQL: master1 ::: SELECT user_id,name,sex FROM tb_newinfo
WHERE user_id=? ::: [111]
```
### sharding.yml
```
dataSources:
master0:
dataSourceClassName: com.alibaba.druid.pool.DruidDataSource
driverClassName: org.postgresql.Driver
url: jdbc:postgresql://20.198.250.10:5435/db1
username: dbuser
password: dbpwd
master1:
dataSourceClassName: com.alibaba.druid.pool.DruidDataSource
driverClassName: org.postgresql.Driver
url: jdbc:postgresql://20.198.250.10:5435/db2
username: dbuser
password: dbpwd
slave0:
dataSourceClassName: com.alibaba.druid.pool.DruidDataSource
driverClassName: org.postgresql.Driver
url: jdbc:postgresql://20.198.250.10:5435/db3
username: dbuser
password: dbpwd
slave1:
dataSourceClassName: com.alibaba.druid.pool.DruidDataSource
driverClassName: org.postgresql.Driver
url: jdbc:postgresql://20.198.250.10:5435/db4
username: dbuser
password: dbpwd
rules:
- !SHARDING
tables:
tb_newinfo:
actualDataNodes: master${0..1}.tb_newinfo
defaultDatabaseStrategy:
standard:
shardingColumn: user_id
shardingAlgorithmName: db_inline
shardingAlgorithms:
db_inline:
type: INLINE
props:
algorithm-expression: master${userid %
2}
- !READWRITE_SPLITTING
dataSources:
readwrite0:
writeDataSourceName: master0
readDataSourceNames:
-slave0
loadBalancerName: lb1
readwrite1:
writeDataSourceName: master1
readDataSourceNames:
-slave1
loadBalancerName: lb1
loadBalancers:
lb1:
type: ROUND_ROBIN
props:
sql-show: true
```
--
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:
[email protected]
For queries about this service, please contact Infrastructure at:
[email protected]