Skip to content
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

Automatic Data rebalancing by adding new data node #34813

Open
jainanuj07 opened this issue Feb 27, 2025 · 4 comments
Open

Automatic Data rebalancing by adding new data node #34813

jainanuj07 opened this issue Feb 27, 2025 · 4 comments

Comments

@jainanuj07
Copy link

I have set up ShardingSphere-Proxy with two data sources and defined a sharding rule using the MOD function on the ID column. After adding a new data source, I noticed that new data is being distributed across the updated nodes, but the existing data remains on the original instances.

Does ShardingSphere support automatic rebalancing when a new data source is added?

@jainanuj07
Copy link
Author

@terrymanu can you pls help.

@terrymanu
Copy link
Member

What is the version and config

@jainanuj07
Copy link
Author

jainanuj07 commented Mar 6, 2025

Version : 5.5.2

data:
config-sharding.yaml: |
databaseName: api-beta-test
dataSources:
ds_0:
url:
username:
password:
ds_1:
url:
username:
password:
rules:
- !SHARDING
tables:
payments:
actualDataNodes: ds_0.payments_0, ds_1.payments_1
tableStrategy:
standard:
shardingColumn: merchant_id
shardingAlgorithmName: payments_table_algorithm
keyGenerateStrategy:
column: id
keyGeneratorName: snowflake
defaultDatabaseStrategy:
standard:
shardingColumn: merchant_id
shardingAlgorithmName: database_sharding_algorithm
defaultTableStrategy:
none: {}
shardingAlgorithms:
database_sharding_algorithm:
type: INLINE
props:
algorithm-expression: ds_${Math.abs(merchant_id.hashCode()) % 2 }
payments_table_algorithm:
type: INLINE
props:
algorithm-expression: payments_${Math.abs(merchant_id.hashCode()) % 2}
keyGenerators:
snowflake:
type: SNOWFLAKE

This is my current config and now I want to add one more datasource and shard the data for some merchants to new data source. So I will add and change the hash mod algo. This is my new Config.

data:
config-sharding.yaml: |
databaseName: api-beta-test
dataSources:
ds_0:
url:
username:
password:
ds_1:
url:
username:
password:
ds_2:
url:
username:
password:
rules:
- !SHARDING
tables:
payments:
actualDataNodes: ds_0.payments_0, ds_1.payments_1,ds_2.payments_2
tableStrategy:
standard:
shardingColumn: merchant_id
shardingAlgorithmName: payments_table_algorithm
keyGenerateStrategy:
column: id
keyGeneratorName: snowflake
defaultDatabaseStrategy:
standard:
shardingColumn: merchant_id
shardingAlgorithmName: database_sharding_algorithm
defaultTableStrategy:
none: {}
shardingAlgorithms:
database_sharding_algorithm:
type: INLINE
props:
algorithm-expression: ds_${Math.abs(merchant_id.hashCode()) % 3 }
payments_table_algorithm:
type: INLINE
props:
algorithm-expression: payments_${Math.abs(merchant_id.hashCode()) % 3}
keyGenerators:
snowflake:
type: SNOWFLAKE

@terrymanu
Copy link
Member

The SphereEx enterprise version include this feature:
https://www.sphere-ex.cn/comparison/

ShardingSphere currently remains focused on managing database traffic and has no immediate plans to expand its product feature scope.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants