strongduanmu commented on issue #10996:
URL: 
https://github.com/apache/shardingsphere/issues/10996#issuecomment-890785146


   When I tested the read-write separation scenario and configured multiple 
data, the metadata was incorrectly loaded during single table refresh.
   
   ```java
   private TableMetaData loadTableMetaData(final String tableName, final 
Collection<String> routeDataSourceNames, 
                                           final SchemaBuilderMaterials 
materials) throws SQLException {
       for (String routeDataSourceName : routeDataSourceNames) {
           DataSource dataSource = 
materials.getDataSourceMap().get(routeDataSourceName);
           Optional<TableMetaData> tableMetaDataOptional = 
Objects.isNull(dataSource) ? Optional.empty()
                   : TableMetaDataLoader.load(dataSource, tableName, 
materials.getDatabaseType());
           if (!tableMetaDataOptional.isPresent()) {
               continue;
           }
           return tableMetaDataOptional.get();
       }
       return new TableMetaData();
   }
   ```
   
   The `routeDataSourceNames` parameter passes the logical data source name, 
and `materials.getDataSourceMap()` returns the real data source name in the 
configuration file, so you need to convert routeDataSourceNames to the real 
data source name, otherwise abnormal results will occur when the metadata 
refreshes.
   


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