{"record":{"id":"0cbefbaee60ad220","repo":"MyCATApache/Mycat-Server","slug":"can-t-find-valid-data-node-s-for-some-of-specifie-0cbefb","errorCode":null,"errorMessage":"Can't find valid data node(s) for some of specified node indexes : + tableConfig.getName() +  ->  + tableConfig.getPartitionColumn()","messagePattern":"Can't find valid data node\\(s\\) for some of specified node indexes : \\+ tableConfig\\.getName\\(\\) \\+  ->  \\+ tableConfig\\.getPartitionColumn\\(\\)","errorType":"exception","errorClass":"SQLNonTransientException","httpStatus":null,"severity":"error","filePath":"src/main/java/io/mycat/route/util/RouterUtil.java","lineNumber":1721,"sourceCode":"\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\tif(algorithm instanceof SlotFunction){\r\n\t\t\t\t\t\t\t\t\t\trrs.getDataNodeSlotMap().put(node,((SlotFunction) algorithm).slotValue());\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\ttablesRouteMap.get(tableName).add(node);\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\tif(pair.rangeValue != null) {\r\n\t\t\t\t\t\t\t\tInteger[] nodeIndexs = algorithm\r\n\t\t\t\t\t\t\t\t\t\t.calculateRange(pair.rangeValue.beginValue.toString(), pair.rangeValue.endValue.toString());\r\n\t\t\t\t\t\t\t\tArrayList<String> dataNodes = tableConfig.getDataNodes();\r\n\t\t\t\t\t\t\t\tString node;\r\n\t\t\t\t\t\t\t\tfor(Integer idx : nodeIndexs) {\r\n\t\t\t\t\t\t\t\t\tif (idx >= 0 && idx < dataNodes.size()) {\r\n\t\t\t\t\t\t\t\t\t\tnode = dataNodes.get(idx);\r\n\t\t\t\t\t\t\t\t\t} else {\r\n\t\t\t\t\t\t\t\t\t\tString msg = \"Can't find valid data node(s) for some of specified node indexes :\"\r\n\t\t\t\t\t\t\t\t\t\t\t\t+ tableConfig.getName() + \" -> \" + tableConfig.getPartitionColumn();\r\n\t\t\t\t\t\t\t\t\t\tLOGGER.warn(msg);\r\n\t\t\t\t\t\t\t\t\t\tthrow new SQLNonTransientException(msg);\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\tif(node != null) {\r\n\t\t\t\t\t\t\t\t\t\tif(tablesRouteMap.get(tableName) == null) {\r\n\t\t\t\t\t\t\t\t\t\t\ttablesRouteMap.put(tableName, new HashSet<String>());\r\n\t\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t\tif(algorithm instanceof SlotFunction){\r\n\t\t\t\t\t\t\t\t\t\t\trrs.getDataNodeSlotMap().put(node,((SlotFunction) algorithm).slotValue());\r\n\t\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t\ttablesRouteMap.get(tableName).add(node);\r\n\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t} else if(joinKey != null && columnsMap.get(joinKey) != null && columnsMap.get(joinKey).size() != 0) {//childTable  (如果是select 语句的父子表join)之前要找到root table,将childTable移除,只留下root table\r\n\t\t\t\t\tSet<ColumnRoutePair> joinKeyValue = columnsMap.get(joinKey);\r","sourceCodeStart":1703,"sourceCodeEnd":1739,"githubUrl":"https://github.com/MyCATApache/Mycat-Server/blob/65f8d8beb752f935752f2a0eec0ab017facab9ef/src/main/java/io/mycat/route/util/RouterUtil.java#L1703-L1739","documentation":"Thrown by RouterUtil when a route calculation resolves node indexes for a sharded table, but one or more indexes are outside the bounds of the table's configured dataNodes list. MyCat refuses to route to a nonexistent node and fails the SQL with SQLNonTransientException. It almost always means the partition rule produces indexes that don't match the table's dataNode configuration.","triggerScenarios":"Executing a SELECT/INSERT/UPDATE routed through ruleResult/RouterUtil.routeToMultiNode (or routeByER/routeToSomeNode) where the partition algorithm returns a node index idx that is <0 or >= dataNodes.size() for tableConfig.getName().","commonSituations":"Shard count in rule.xml/partition algorithm (e.g. partitionByMod count) larger than the number of <dataNode> entries configured for the table; rule config changed after data nodes were reduced; hash/mod value produces an out-of-range bucket; copy-pasted table config with mismatched node counts.","solutions":["Align the partition algorithm's count with the number of dataNodes declared for the table in schema.xml (e.g. mod partition count == number of dataNode entries).","Check schema.xml: every table using the rule must list at least as many dataNodes as the function can return.","Log the computed partition value and index for the failing row to identify which values map out of range.","If nodes were intentionally scaled down, re-shard data or switch to a partition function whose range covers the actual node count."],"exampleFix":"// before (rule.xml)\n<function name=\"mod-long\" class=\"io.mycat.route.function.PartitionByMod\"><property name=\"count\">10</property></function>\n<!-- but table only has 4 dataNodes -->\n\n// after\n<function name=\"mod-long\" class=\"io.mycat.route.function.PartitionByMod\"><property name=\"count\">4</property></function>","handlingStrategy":"validation","validationCode":"// Validate partition index against configured node count before issuing SQL\nint idx = partition(value);\nList<String> dataNodes = tableConfig.getDataNodes();\nif (idx < 0 || idx >= dataNodes.size()) {\n    throw new IllegalArgumentException(\"partition index \" + idx + \" out of range for \" + tableConfig.getName() + \" (\" + dataNodes.size() + \" nodes)\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep partition function count equal to dataNode count for every sharded table","Run MyCat's partition function unit test (e.g. PartitionByModTest) after config changes","Review schema.xml and rule.xml together in code review"],"tags":["routing","sharding","configuration","data-node"],"backgroundTag":"invalid-config-value","analyzedSha":"65f8d8beb752f935752f2a0eec0ab017facab9ef","analyzedAt":"2026-09-11T00:12:21.696Z","contentChangedAt":"2026-09-11T00:12:21.696Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}