You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2022/10/10 06:32:15 UTC
[GitHub] [shardingsphere] xiongmaodeguxiang opened a new issue, #20679: Using the Snowflake algorithm + HashMod has problems when the same shard fields of the table are created by BindingTableGroups
xiongmaodeguxiang opened a new issue, #20679:
URL: https://github.com/apache/shardingsphere/issues/20679
using shardingsphere-jdbc 5.0.0
hashShardingValue in HashModShardingAlgorithm like this
```
private long hashShardingValue(final Comparable<?> shardingValue) {
return Math.abs((long) shardingValue.hashCode());
}
```
When using snowflake algorithm, shardingValue is a Long type, the same Long value will be different hashCode, so when using BindingTableGroups, the associated table query will not be able to query data
--
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: notifications-unsubscribe@shardingsphere.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] github-actions[bot] closed issue #20679: Using the Snowflake algorithm + HashMod has problems when the same shard fields of the table are created by BindingTableGroups
Posted by GitBox <gi...@apache.org>.
github-actions[bot] closed issue #20679: Using the Snowflake algorithm + HashMod has problems when the same shard fields of the table are created by BindingTableGroups
URL: https://github.com/apache/shardingsphere/issues/20679
--
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: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] RaigorJiang commented on issue #20679: Using the Snowflake algorithm + HashMod has problems when the same shard fields of the table are created by BindingTableGroups
Posted by "RaigorJiang (via GitHub)" <gi...@apache.org>.
RaigorJiang commented on issue #20679:
URL: https://github.com/apache/shardingsphere/issues/20679#issuecomment-1407628177
Please refer to the [documentation](https://shardingsphere.apache.org/document/current/en/user-manual/common-config/builtin-algorithm/sharding/) to learn about the differences in sharding algorithms.
If you have any problems, please reopen this issue or submit a new one.
--
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: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] RaigorJiang commented on issue #20679: Using the Snowflake algorithm + HashMod has problems when the same shard fields of the table are created by BindingTableGroups
Posted by "RaigorJiang (via GitHub)" <gi...@apache.org>.
RaigorJiang commented on issue #20679:
URL: https://github.com/apache/shardingsphere/issues/20679#issuecomment-1407627810
`hash_mod` is an auto sharding algorithm, please do not use inline expressions to configure dataNodes.
We will enhance the validation in this area, this is a wrong way to use it.
--
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: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] RaigorJiang closed issue #20679: Using the Snowflake algorithm + HashMod has problems when the same shard fields of the table are created by BindingTableGroups
Posted by "RaigorJiang (via GitHub)" <gi...@apache.org>.
RaigorJiang closed issue #20679: Using the Snowflake algorithm + HashMod has problems when the same shard fields of the table are created by BindingTableGroups
URL: https://github.com/apache/shardingsphere/issues/20679
--
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: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] xiongmaodeguxiang commented on issue #20679: Using the Snowflake algorithm + HashMod has problems when the same shard fields of the table are created by BindingTableGroups
Posted by GitBox <gi...@apache.org>.
xiongmaodeguxiang commented on issue #20679:
URL: https://github.com/apache/shardingsphere/issues/20679#issuecomment-1232665605
Configuration is as follows:
`ShardingRuleConfiguration ruleConfiguration = new ShardingRuleConfiguration();
ruleConfiguration.getBindingTableGroups().add("t_order,t_order_item");
ShardingTableRuleConfiguration tableRuleConfiguration = new ShardingTableRuleConfiguration("t_user","ds$->{0..1}.t_user_$->{0..3}");
tableRuleConfiguration.setDatabaseShardingStrategy(new StandardShardingStrategyConfiguration("user_id","db_mode_algorithm"));
tableRuleConfiguration.setTableShardingStrategy(new StandardShardingStrategyConfiguration("user_id","tab_mode_algorithm"));
ShardingTableRuleConfiguration orderTableRuleConfiguration = new ShardingTableRuleConfiguration("t_order","ds$->{0..1}.t_order_$->{0..3}");
orderTableRuleConfiguration.setDatabaseShardingStrategy(new StandardShardingStrategyConfiguration("order_id","db_mode_algorithm"));
orderTableRuleConfiguration.setTableShardingStrategy(new StandardShardingStrategyConfiguration("order_id","tab_mode_algorithm"));
orderTableRuleConfiguration.setKeyGenerateStrategy(new KeyGenerateStrategyConfiguration("order_id","snowflake"));
ShardingTableRuleConfiguration orderItemTableRuleConfiguration = new ShardingTableRuleConfiguration("t_order_item","ds$->{0..1}.t_order_item_$->{0..3}");
orderItemTableRuleConfiguration.setDatabaseShardingStrategy(new StandardShardingStrategyConfiguration("order_id","db_mode_algorithm"));
orderItemTableRuleConfiguration.setTableShardingStrategy(new StandardShardingStrategyConfiguration("order_id","tab_mode_algorithm"));
ruleConfiguration.getTables().add(orderItemTableRuleConfiguration);
ruleConfiguration.getTables().add(orderTableRuleConfiguration);
ruleConfiguration.getTables().add(tableRuleConfiguration);
Properties dbProps = new Properties();
dbProps.setProperty("sharding-count","2");
Properties tabProps = new Properties();
tabProps.setProperty("sharding-count","4");
ruleConfiguration.getShardingAlgorithms().put("db_mode_algorithm", new ShardingSphereAlgorithmConfiguration("HASH_MOD",dbProps));
ruleConfiguration.getShardingAlgorithms().put("tab_mode_algorithm",new ShardingSphereAlgorithmConfiguration("HASH_MOD",tabProps));
Properties keyGenerProps = new Properties();
keyGenerProps.setProperty("worker-id","123");
ruleConfiguration.getKeyGenerators().put("snowflake",new ShardingSphereAlgorithmConfiguration("SNOWFLAKE",keyGenerProps));`
--
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: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] xiongmaodeguxiang commented on issue #20679: Using the Snowflake algorithm + HashMod has problems when the same shard fields of the table are created by BindingTableGroups
Posted by GitBox <gi...@apache.org>.
xiongmaodeguxiang commented on issue #20679:
URL: https://github.com/apache/shardingsphere/issues/20679#issuecomment-1232667753
Configuration is as follows:
`ShardingRuleConfiguration ruleConfiguration = new ShardingRuleConfiguration();
ruleConfiguration.getBindingTableGroups().add("t_order,t_order_item");
ShardingTableRuleConfiguration tableRuleConfiguration = new ShardingTableRuleConfiguration("t_user","ds$->{0..1}.t_user_$->{0..3}");
tableRuleConfiguration.setDatabaseShardingStrategy(new StandardShardingStrategyConfiguration("user_id","db_mode_algorithm"));
tableRuleConfiguration.setTableShardingStrategy(new StandardShardingStrategyConfiguration("user_id","tab_mode_algorithm"));
ShardingTableRuleConfiguration orderTableRuleConfiguration = new ShardingTableRuleConfiguration("t_order","ds$->{0..1}.t_order_$->{0..3}");
orderTableRuleConfiguration.setDatabaseShardingStrategy(new StandardShardingStrategyConfiguration("order_id","db_mode_algorithm"));
orderTableRuleConfiguration.setTableShardingStrategy(new StandardShardingStrategyConfiguration("order_id","tab_mode_algorithm"));
orderTableRuleConfiguration.setKeyGenerateStrategy(new KeyGenerateStrategyConfiguration("order_id","snowflake"));
ShardingTableRuleConfiguration orderItemTableRuleConfiguration = new ShardingTableRuleConfiguration("t_order_item","ds$->{0..1}.t_order_item_$->{0..3}");
orderItemTableRuleConfiguration.setDatabaseShardingStrategy(new StandardShardingStrategyConfiguration("order_id","db_mode_algorithm"));
orderItemTableRuleConfiguration.setTableShardingStrategy(new StandardShardingStrategyConfiguration("order_id","tab_mode_algorithm"));`
`ruleConfiguration.getTables().add(orderItemTableRuleConfiguration);
ruleConfiguration.getTables().add(orderTableRuleConfiguration);
ruleConfiguration.getTables().add(tableRuleConfiguration);
Properties dbProps = new Properties();
dbProps.setProperty("sharding-count","2");
Properties tabProps = new Properties();
tabProps.setProperty("sharding-count","4");
ruleConfiguration.getShardingAlgorithms().put("db_mode_algorithm", new ShardingSphereAlgorithmConfiguration("HASH_MOD",dbProps));
ruleConfiguration.getShardingAlgorithms().put("tab_mode_algorithm",new ShardingSphereAlgorithmConfiguration("HASH_MOD",tabProps));
Properties keyGenerProps = new Properties();
keyGenerProps.setProperty("worker-id","123");
ruleConfiguration.getKeyGenerators().put("snowflake",new ShardingSphereAlgorithmConfiguration("SNOWFLAKE",keyGenerProps));``
--
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: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] xiongmaodeguxiang closed issue #20679: Using the Snowflake algorithm + HashMod has problems when the same shard fields of the table are created by BindingTableGroups
Posted by GitBox <gi...@apache.org>.
xiongmaodeguxiang closed issue #20679: Using the Snowflake algorithm + HashMod has problems when the same shard fields of the table are created by BindingTableGroups
URL: https://github.com/apache/shardingsphere/issues/20679
--
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: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] xiongmaodeguxiang closed issue #20679: Using the Snowflake algorithm + HashMod has problems when the same shard fields of the table are created by BindingTableGroups
Posted by GitBox <gi...@apache.org>.
xiongmaodeguxiang closed issue #20679: Using the Snowflake algorithm + HashMod has problems when the same shard fields of the table are created by BindingTableGroups
URL: https://github.com/apache/shardingsphere/issues/20679
--
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: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] github-actions[bot] commented on issue #20679: Using the Snowflake algorithm + HashMod has problems when the same shard fields of the table are created by BindingTableGroups
Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on issue #20679:
URL: https://github.com/apache/shardingsphere/issues/20679#issuecomment-1272348654
Hello , this issue has not received a reply for several days.
This issue is supposed to be closed.
--
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: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org