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

Unique actual data nodes issue in sharding rule checker #34251

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public void check(final ShardingRuleConfiguration ruleConfig) {

private void checkUniqueActualDataNodesInTableRules() {
Collection<DataNode> uniqueActualDataNodes = new HashSet<>(shardingRule.getShardingTables().size(), 1F);
shardingRule.getShardingTables().forEach((key, value) -> checkUniqueActualDataNodes(uniqueActualDataNodes, key, value.getActualDataNodes().iterator().next()));
shardingRule.getShardingTables().forEach((key, value) -> value.getActualDataNodes().forEach(each -> checkUniqueActualDataNodes(uniqueActualDataNodes, key, each)));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If actualDataNodes contains many nodes, checking all nodes will take more time. Is it possible to add a props to control whether to check all actualDataNodes or sampleDataNode?

}

private void checkUniqueActualDataNodes(final Collection<DataNode> uniqueActualDataNodes, final String logicTable, final DataNode sampleActualDataNode) {
Expand Down Expand Up @@ -191,8 +191,8 @@ public void checkToBeAddedDataNodes(final Map<String, Collection<DataNode>> toBe
if (isAlteration && toBeAddedDataNodes.containsKey(key)) {
return;
}
checkUniqueActualDataNodes(uniqueActualDataNodes, key, value.getActualDataNodes().iterator().next());
value.getActualDataNodes().forEach(each -> checkUniqueActualDataNodes(uniqueActualDataNodes, key, each));
});
toBeAddedDataNodes.forEach((key, value) -> checkUniqueActualDataNodes(uniqueActualDataNodes, key, value.iterator().next()));
toBeAddedDataNodes.forEach((key, value) -> value.forEach(each -> checkUniqueActualDataNodes(uniqueActualDataNodes, key, each)));
}
}
Loading