MyCATApache/Mycat-Server · error · SQLNonTransientException
find no Route:
Error message
find no Route:
What it means
DruidSelectParser, after evaluating all routing conditions for a SELECT (sharding keys, global tables, broadcast rules), found an empty nodeSet — no datanode matches the query. It throws SQLNonTransientException ' find no Route:' followed by the SQL text.
Solutions
- Include the sharding/partition column in the WHERE clause so a datanode can be selected
- Mark the table as global in schema.xml if it is a small lookup table broadcast to all nodes
- Review the sharding rule in rule.xml to ensure the queried value maps to a node
- If full-table scans are intended, configure the table/route strategy to broadcast to all datanodes
Example fix
// before SELECT * FROM orders; // after (orders sharded by customer_id) SELECT * FROM orders WHERE customer_id = 123;
Defensive patterns
Strategy: validation
Validate before calling
if (!whereContainsShardingColumn(sql, table)) log.warn("query on sharded table without sharding column may fail routing: " + table); Try / catch
try { query(sql); } catch (SQLNonTransientException e) { if (e.getMessage().startsWith(" find no Route:")) { fallbackToBroadcastOrReject(e); } else throw e; } Prevention
- Always filter sharded tables by their sharding key
- Mark lookup tables as global in schema.xml
- Test routing for all query patterns in the app
- Catch the error and fall back to a fan-out query only when full scans are acceptable
When it happens
Trigger: DruidSelectParser routing a SELECT where no WHERE-condition on the sharding column, ER join, or global-table rule yields any RouteResultsetNode — typically a query with no usable sharding condition on a non-global sharded table that has no broadcast fallback configured.
Common situations: SELECT on a sharded table without including the sharding column in WHERE; sharding rule misconfigured so no node matches; join conditions not recognized by MyCat's ER analysis; global table flag missing so cross-node queries can't resolve.
Understand the failure class
Background: EmptyResultError / "no results found": when an API or scraper succeeds but returns zero rows — this error's family across 9 libraries.
Related errors
- can't find any valid datanode : -> ->
- " find no Route:" + ctx.getSql()
- can't find any valid datanode : + tableConfig.getName() + …
- Can't find a valid data node for specified node index : +…
- schema: ,table: ,sql: is not allowed,because table is…
AI-assisted analysis of MyCATApache/Mycat-Server@65f8d8beb7 (2026-09-11).
Data as JSON: /api/errors/ca11d0a3eb7b1228.
Report an issue: GitHub.
Appendix: source
Thrown at src/main/java/io/mycat/route/parser/druid/impl/DruidSelectParser.java:618
for(String key: ctx.getTableAliasMap().keySet()){
TableConfig tb_config = schema.getTables().get(key.toUpperCase());
if(tb_config!=null){
String table_name = ctx.getTableAliasMap().get(key);
for(String dataNode:tb_config.getDataNodes()){
if(tb_config.getDataNodes().size()==1 || table_name.startsWith(dataNode+'.')){
rrs = RouterUtil.routeToSingleNode(rrs, dataNode, ctx.getSql());
rrs.setFinishedRoute(true);
return;
}
}
}
}
}
//end@byron
String msg = " find no Route:" + ctx.getSql();
LOGGER.warn(msg);
throw new SQLNonTransientException(msg);
}
RouteResultsetNode[] nodes = new RouteResultsetNode[nodeSet.size()];
int i = 0;
for (Iterator<RouteResultsetNode> iterator = nodeSet.iterator(); iterator.hasNext();) {
nodes[i] = (RouteResultsetNode) iterator.next();
i++;
}
rrs.setNodes(nodes);
rrs.setFinishedRoute(true);
}
protected String getCurentDbType()
{
return JdbcConstants.MYSQL.name();
View on GitHub (pinned to 65f8d8beb7)