{"record":{"id":"e141fefd742940cb","repo":"apache/shardingsphere","slug":"2","errorCode":"2","errorMessage":"Can not find data source in sharding rule, invalid actual data node '%s'.","messagePattern":"Can not find data source in sharding rule, invalid actual data node '(.+?)'\\.","errorType":"exception","errorClass":"DataNodeGenerateException","httpStatus":null,"severity":"error","filePath":"features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rule/ShardingTable.java","lineNumber":202,"sourceCode":"        int index = 0;\n        for (String each : dataSourceNames) {\n            DataNode dataNode = new DataNode(each, (String) null, logicTable);\n            result.add(dataNode);\n            dataNodeIndexMap.put(dataNode, index);\n            actualDataSourceNames.add(each);\n            addActualTable(dataNode.getDataSourceName(), dataNode.getTableName());\n            index++;\n        }\n        return result;\n    }\n    \n    private List<DataNode> generateDataNodes(final Collection<String> actualDataNodes, final Collection<String> dataSourceNames) {\n        List<DataNode> result = new ArrayList<>(actualDataNodes.size());\n        int index = 0;\n        for (String each : actualDataNodes) {\n            DataNode dataNode = new DataNode(each);\n            if (!dataSourceNames.contains(dataNode.getDataSourceName())) {\n                throw new DataNodeGenerateException(each);\n            }\n            result.add(dataNode);\n            dataNodeIndexMap.put(dataNode, index);\n            actualDataSourceNames.add(dataNode.getDataSourceName());\n            addActualTable(dataNode.getDataSourceName(), dataNode.getTableName());\n            index++;\n        }\n        return result;\n    }\n    \n    /**\n     * Get data node groups.\n     *\n     * @return data node groups, key is data source name, values are data nodes belong to this data source\n     */\n    public Map<String, List<DataNode>> getDataNodeGroups() {\n        return DataNodeUtils.getDataNodeGroups(actualDataNodes);\n    }","sourceCodeStart":184,"sourceCodeEnd":220,"githubUrl":"https://github.com/apache/shardingsphere/blob/e952770a215630a3659c75d64369168cd3e26b82/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rule/ShardingTable.java#L184-L220","documentation":"DataNodeGenerateException ('Can not find data source in sharding rule, invalid actual data node') is thrown by ShardingTable.generateDataNodes while building the actual data nodes for a sharding table rule. Each configured actual data node string is parsed into (dataSource, tableName); if the parsed data source name is not in the rule's known data source names (dataSourceNames), the node is rejected. It is a configuration-load-time validation of data node expressions.","triggerScenarios":"An actualDataNodes entry like ds_9.t_order_0 where ds_9 is not among the data source names available to the sharding rule (not registered in mode configuration / not in dataSourceNames), or an inline expression that expands to an unconfigured data source index.","commonSituations":"Typo in the data source prefix; inline expression ds_${0..4} when only ds_0..ds_2 exist; renaming a data source without updating sharding rules; adding a rule via DistSQL before registering the data source (REGISTER STORAGE UNIT).","solutions":["Register the missing data source first (REGISTER STORAGE UNIT / add to dataSources) before creating or altering the sharding rule.","Fix the actualDataNodes expression to reference only configured data sources (correct range or prefix).","After renaming/removing storage units, update every sharding rule that references them."],"exampleFix":"-- before: ds_9 not registered\nCREATE SHARDING TABLE RULE t_order (\n  DATANODES(\"ds_9.t_order_${0..3}\"), ...\n);\n\n-- after: register units, then reference them\nREGISTER STORAGE UNIT ds_0 (...), ds_1 (...);\nCREATE SHARDING TABLE RULE t_order (\n  DATANODES(\"ds_${0..1}.t_order_${0..3}\"), ...\n);","handlingStrategy":"validation","validationCode":"// Before creating/altering a rule, check every data node's data source is registered\nSet<String> registered = /* storage unit names from SHOW STORAGE UNITS */ Set.of(\"ds_0\", \"ds_1\");\nfor (String node : List.of(\"ds_${0..1}.t_order_${0..3}\".expanded())) { // expand inline expression\n    String ds = node.split(\"\\\\.\")[0];\n    if (!registered.contains(ds)) { throw new IllegalStateException(\"Unregistered data source: \" + ds); }\n}","typeGuard":null,"tryCatchPattern":"try {\n    proxySession.executeddl(\"CREATE SHARDING TABLE RULE ...\");\n} catch (final DataNodeGenerateException ex) {\n    // register the missing storage unit, then re-apply the rule\n}","preventionTips":["Always REGISTER STORAGE UNIT before referencing new data sources in rules.","Keep inline expression ranges in sync with the number of registered data sources."],"tags":["sharding","data-node","configuration","storage-unit","startup"],"backgroundTag":null,"analyzedSha":"e952770a215630a3659c75d64369168cd3e26b82","analyzedAt":"2026-08-14T13:54:53.392Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}