strongyc commented on issue #20845:
URL: 
https://github.com/apache/shardingsphere/issues/20845#issuecomment-1239005799

   > Hi @strongyc, thank you for your feedback. Can you modify the title for 
searching friendly? Besides, can you format your issue with markdown?
   
   ### 1.problem
   
   Using version 5.1.2, after configuring read-write separation and data 
fragmentation, the fragmented table cannot be read from the slave library, and 
other tables can read from the slave library normally. Why  
   
   ## 2. Which version of ShardingSphere did you use?
   
   5.1.2
   
   ### 3. Which project did you use? ShardingSphere-JDBC or 
ShardingSphere-Proxy?
   
   ShardingSphere-JDBC
   
   ## 4.settings
   
   springboot2.7.3+MybaitsPlus3.5.2+shardingShere5.1.2
   
   ```
   spring:
     shardingsphere:
       mode:
         type: Memory
       datasource:
         names: db1,db2
         db1:
           driver-class-name: com.mysql.cj.jdbc.Driver
           jdbc-url: 
jdbc:mysql://192.168.37.130:3306/student?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai
           username: root
           password: 
           type: com.zaxxer.hikari.HikariDataSource
         db2:
           driver-class-name: com.mysql.cj.jdbc.Driver
           jdbc-url: 
jdbc:mysql://192.168.37.132:3306/student?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai
           username: root
           password: 
           type: com.zaxxer.hikari.HikariDataSource
       rules:
         sharding:
           tables:
             document:
               actual-data-nodes: db1.document_$->{2013..2022}
               table-strategy:
                 standard:
                   sharding-algorithm-name: document-inline # 分片算法名称
                   sharding-column: document_year
               key-generate-strategy:
                 column: id
                 key-generator-name: timestamp #主键生成算法#主键生成算法
           sharding-algorithms:
             document-inline:
               type: INLINE
               props:
                 algorithm-expression: document_$->{document_year}
           key-generators:
             timestamp:
               type: SNOWFLAKE
   
         readwrite-splitting:
           data-sources:
             read_write_db:
               type: Static
               props:
                 write-data-source-name: db1
                 read-data-source-names: db2
               load-balancer-name: round_robin
           load-balancers:
             round_robin:
               type: ROUND_ROBIN
   
       props:
         sql-show: true
   
   ```
   
   ### 5.results of enforcement
   
   2022-09-07 13:52:50.801 INFO 25968 --- [nio-8080-exec-1] ShardingSphere-SQL 
: Actual SQL: db1 ::: SELECT id,document_name,document_detail,document_year 
FROM document_2013 UNION ALL SELECT 
id,document_name,document_detail,document_year FROM document_2014 UNION ALL 
SELECT id,document_name,document_detail,document_year FROM document_2015 UNION 
ALL SELECT id,document_name,document_detail,document_year FROM document_2016 
UNION ALL SELECT id,document_name,document_detail,document_year FROM 
document_2017 UNION ALL SELECT id,document_name,document_detail,document_year 
FROM document_2018 UNION ALL SELECT 
id,document_name,document_detail,document_year FROM document_2019 UNION ALL 
SELECT id,document_name,document_detail,document_year FROM document_2020 UNION 
ALL SELECT id,document_name,document_detail,document_year FROM document_2021 
UNION ALL SELECT id,document_name,document_detail,document_year FROM 
document_2022
   
   ## 6.why?
   
   According to the configuration, db1 is the master library and db2 is the 
slave Library,why is db1


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