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

ShardingUnicastRoutingEngine provides an incorrect ActualDataNode #29005

Open
zhangOranges opened this issue Nov 10, 2023 · 2 comments · May be fixed by #29021
Open

ShardingUnicastRoutingEngine provides an incorrect ActualDataNode #29005

zhangOranges opened this issue Nov 10, 2023 · 2 comments · May be fixed by #29021
Labels

Comments

@zhangOranges
Copy link

zhangOranges commented Nov 10, 2023

Version: 5.1.0
Class:org.apache.shardingsphere.sharding.route.engine.type.unicast.ShardingUnicastRoutingEngine


     public RouteContext route(final ShardingRule shardingRule) {
         RouteContext result = new RouteContext();
         String dataSourceName = getRandomDataSourceName(shardingRule.getDataSourceNames());
         RouteMapper dataSourceMapper = new RouteMapper(dataSourceName, dataSourceName);
         if (shardingRule.isAllBroadcastTables(logicTables)) {
             List<RouteMapper> tableMappers = new ArrayList<>(logicTables.size());
             for (String each : logicTables) {
                 tableMappers.add(new RouteMapper(each, each));
             }
             result.getRouteUnits().add(new RouteUnit(dataSourceMapper, tableMappers));
         } else if (logicTables.isEmpty()) {
             result.getRouteUnits().add(new RouteUnit(dataSourceMapper, Collections.emptyList()));
         } else if (1 == logicTables.size()) {
             String logicTableName = logicTables.iterator().next();
             if (!shardingRule.findTableRule(logicTableName).isPresent()) {
                 result.getRouteUnits().add(new RouteUnit(dataSourceMapper, Collections.emptyList()));
                 return result;
             }
             DataNode dataNode = shardingRule.getDataNode(logicTableName);
             result.getRouteUnits().add(new RouteUnit(new RouteMapper(dataNode.getDataSourceName(), dataNode.getDataSourceName()),
                     Collections.singletonList(new RouteMapper(logicTableName, dataNode.getTableName()))));
         } else {
             routeWithMultipleTables(result, shardingRule);
         }
         return result;
     }

shardingRule.getDataNode method
Class:org.apache.shardingsphere.sharding.rule.ShardingRule

public DataNode getDataNode(final String logicTableName) {
    TableRule tableRule = getTableRule(logicTableName);
    return tableRule.getActualDataNodes().get(0);
}

Directly get (0) here
If I choose one, the results of my query will not be correct. Should I return all the actual nodes here?

@zhangOranges
Copy link
Author

What is the purpose of the AlwaysFalseSharingConditionValue design?

zhangOranges added a commit to zhangOranges/shardingsphere that referenced this issue Nov 13, 2023
@zhangOranges zhangOranges linked a pull request Nov 13, 2023 that will close this issue
Copy link

There hasn't been any activity on this issue recently, and in order to prioritize active issues, it will be marked as stale.

@github-actions github-actions bot added the stale label Dec 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant