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

   * dependency: 
   shardingsphere-jdbc-core-spring-boot-starter 
   5.1.2
   
   
   * configuration: 
   
[config.txt](https://github.com/apache/shardingsphere/files/14556667/config.txt)
   
   
   
   * debug :
   ```
       @Bean
       @Conditional({LocalRulesCondition.class})
       @Autowired(
           required = false
       )
       public DataSource 
shardingSphereDataSource(ObjectProvider<List<RuleConfiguration>> rules, 
ObjectProvider<ModeConfiguration> modeConfig) throws SQLException {
           Collection<RuleConfiguration> ruleConfigs = 
(Collection)Optional.ofNullable((List)rules.getIfAvailable()).orElseGet(Collections::emptyList);
           return 
ShardingSphereDataSourceFactory.createDataSource(this.databaseName, 
(ModeConfiguration)modeConfig.getIfAvailable(), this.dataSourceMap, 
ruleConfigs, this.props.getProps());
       }
   ```
   
   the breakPoint pause here seems Good because I can find: ruleConfigs  -> 
keyGenerators -> SnowflakeKeyGenerateAlgorithm  -> props -> “worker-id”  : 21,  
   which is exactly in the above configuration.
   
   but after 
"`ShardingSphereDataSourceFactory.createDataSource(this.databaseName, 
(ModeConfiguration)modeConfig.getIfAvailable(), this.dataSourceMap, 
ruleConfigs, this.props.getProps())`"       ,   
    the returned ShardingSphereDataSource -> contextManager -> InstanceContext 
-> ComputeNodeInstance -> workerId is always 0. When I tested(tried to insert 
the table which was using snowflake as keyGenerateAlgorithm),  in the 
breakpoint 
    pause I could find SnowFlakeKeyGenerateAlgorithm  has props: worker-id: 20. 
but when generating Long key,  it was using the InstanceContext-> 
getWorkerId(0),  rather than  props->worker-id(21)。
   
   so "Is there any way to solve this problem?   


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