Closed huanghao495430759 closed 3 years ago
Hi @huanghao495430759 ,
If you use sharding
and replica
feature together, it is necessary to configure sharding Rule
with replica-query data-source-name
. The reason is that sharding rule
will regard replica-query dataName
as a regular dataName
without caring about query executed on replica or primary.
Hi @huanghao495430759 ,
If you use
sharding
andreplica
feature together, it is necessary to configuresharding Rule
withreplica-query data-source-name
. The reason is thatsharding rule
will regardreplica-query dataName
as a regulardataName
without caring about query executed on replica or primary.
Thanks ! I got it.
Which version of ShardingSphere did you use?
5.0.0-RC1-SNAPSHOT I use spring-boot starter
Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
ShardingSphere-JDBC
Expected behavior
my query-sql[select id,user_id,name from user where user_id=1] executed in replica datasource.
Actual behavior
my query-sql[select id,user_id,name from user where user_id=1] executed in primary datasource.
Reason analyze (If you can)
When debug into ReplicaQuerySQLRouter.decorateRouteContext(), it can not find replica datasource, so executed in primary datasource.
Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.
user logic table SQL script:
SQL to execute:
sharding rule configuration:
the result exetuted sql:
after I rename replica-query.data-sources name same as primary data-source-name[node1] :
the result is true.
Example codes for reproduce this issue (such as a github link).