-
Notifications
You must be signed in to change notification settings - Fork 6.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
shardingsphere-jdbc 5.1.2 SnowflakeKeyGenerateAlgorithm workerId not work #30457
Comments
The problem are fixed in 5.4.1. you can try it |
thx, I tried updating to 5.4.1, now I got Application run failed error:
I tried the answer of this question but didnt work something wrong with h2database(2.1.214) or snakeyaml(2.0) version or my configuration? |
Hi guys I solved this problem by following :https://shardingsphere.apache.org/document/current/en/user-manual/shardingsphere-jdbc/yaml-config/jdbc-driver/spring-boot/ This is actually about the configarution, previously we used application-xxx.properties, now we should use sharding.yaml and ShardingSphereDriver. Thanks anyway. |
dependency:
shardingsphere-jdbc-core-spring-boot-starter
5.1.2
configuration:
config.txt
debug :
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?
The text was updated successfully, but these errors were encountered: