theFaustus opened a new issue, #25080:
URL: https://github.com/apache/shardingsphere/issues/25080

   ## 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?
   I have used spring-boot-starters 5.1.2, then tried with 5.2.1 also tried 
with 5.3.2 non-spring-boot starters
   ### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
   Spring Boot, Spring Data Jpa, ShardingSphere-JDBC
   ### Expected behavior
   Writes happen on write datasource (master) and reads happen on read 
datasourse (slave)
   ### Actual behavior
   Reads always go to master no matter what kind of queries I tried.
   Even with simple queries, or @Query, or findById or custom ones it always 
goes to master.
   I've tried solutions mentioned here 
[#15629](https://github.com/apache/shardingsphere/issues/15629) none seemed to 
help.
   
![image](https://user-images.githubusercontent.com/12131801/230868804-5ef6170b-7312-42af-8fcb-53ae0a54ce3c.png)
   
   ### Reason analyze (If you can)
   
   ### Steps to reproduce the behavior, such as: SQL to execute, sharding rule 
configuration, when exception occur etc.
   
   Config for 5.1.2 starter
   ```
   spring:
     jpa:
       properties:
         hibernate:
           dialect: org.hibernate.dialect.PostgreSQL10Dialect
       #        default_schema: reviews
       open-in-view: false
       #    show-sql: true
       #    properties:
       #      hibernate:
       #        format_sql: true
       hibernate:
         ddl-auto: update
     application:
       name: reviews-service
     profiles:
       active: default
   
     shardingsphere:
       datasource:
         names: master,slave0,slave1
   
         master:
           type: com.zaxxer.hikari.HikariDataSource
           driver-class-name: org.postgresql.Driver
           jdbc-url: jdbc:postgresql://localhost:5432/reviews-db
           username: my_user
           password: my_password
           auto-commit: false
   
         slave0:
           type: com.zaxxer.hikari.HikariDataSource
           driver-class-name: org.postgresql.Driver
           jdbc-url: jdbc:postgresql://localhost:64111/reviews-db
           username: my_user
           password: my_password
           auto-commit: false
   
         slave1:
           type: com.zaxxer.hikari.HikariDataSource
           driver-class-name: org.postgresql.Driver
           jdbc-url: jdbc:postgresql://localhost:64110/reviews-db
           username: my_user
           password: my_password
           auto-commit: false
   
       rules:
         sharding:
           tables:
             reviews:
               actual-data-nodes: master.reviews_$->{0..1}
               table-strategy:
                 standard:
                   sharding-column: course_id
                   sharding-algorithm-name: inline
               key-generate-strategy:
                 column: course_id
                 key-generator-name: snowflake
           sharding-algorithms:
             inline:
               type: INLINE
               props:
                 algorithm-expression: reviews_$->{course_id % 2}
                 allow-range-query-with-inline-sharding: true
           key-generators:
             snowflake:
               type: SNOWFLAKE
               props:
                 max-vibration-offset: 1
                 max-tolerate-time-difference-milliseconds: 10
   
         readwrite-splitting:
           data-sources:
             random:
               type: Static
               load-balancer-name: round_robin
               props:
                 write-data-source-name: master
                 read-data-source-names: slave0,slave1
           load-balancers:
             round_robin:
               type: ROUND_ROBIN
   
       props:
         proxy-hint-enabled: true
         sql-show: true
   
   
   management:
     endpoints:
       web:
         exposure:
           include: "*"
     endpoint:
       shutdown:
         enabled: true
       health:
         show-components: always
         show-details: always
     health:
       livenessstate:
         enabled: true
       readinessstate:
         enabled: true
   
   logging:
     level:
       inc.evil: DEBUG
   server:
     port: 8070
   
   ```
   
   Config for 5.2.1 starter (read write splitting)
   ```
         readwrite-splitting:
           data-sources:
             readwrite_ds:
               staticStrategy:
                 writeDataSourceName: master
                 readDataSourceNames:
                   - slave0
                   - slave1
               loadBalancerName: robin
           loadBalancers:
             robin:
               type: ROUND_ROBIN
   ```
   Config for 5.3.2 non-starter (read write splitting)
   ```
     - !READWRITE_SPLITTING
       dataSources:
         readwrite_ds:
           staticStrategy:
             writeDataSourceName: master
             readDataSourceNames:
               - slave
           loadBalancerName: readwrite-load-balancer
       loadBalancers:
         readwrite-load-balancer:
           type: ROUND_ROBIN
   ```
   ### Example codes for reproduce this issue (such as a github link).
   You can take a look at this repo, it is a fairly simple one, it has docker 
containers for postgresql master/slave. And then in commandLineRunner I try to 
do some fetching/inserts, sharding works as expected but as I mentioned the 
reads always go to master.
   You can take a look at the commits to follow my trying process with 
different versions of sharding sphere
   
![image](https://user-images.githubusercontent.com/12131801/230871310-e73fc2ca-309b-416b-983d-a657e943027c.png)
   
   https://github.com/theFaustus/bootiful-sharding


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

Reply via email to