MyCATApache/Mycat-Server · error · SQLNonTransientException
" find no Route:" + ctx.getSql()
Error message
" find no Route:" + ctx.getSql()
What it means
During SELECT routing, the Druid parser computes a set of route nodes from the query's sharding conditions. If the resulting node set is empty — no data node matches the query's sharding key values or no partition column is present — Mycat cannot determine where to send the query and throws SQLNonTransientException with the offending SQL.
Solutions
- Include the sharding/partition column with a routable value in the WHERE clause of the SELECT
- Define the table's sharding algorithm so full-table scans (no sharding key) route to all nodes, or declare it as a global table if it's small
- Use a `/*datanode=...*/` or `/*balance=...*/` hint (e.g. HintDataNodeHandler/HintManager) to force a route
Example fix
-- before SELECT * FROM orders WHERE status = 1; -- after (orders sharded by customer_id) SELECT * FROM orders WHERE customer_id = 123 AND status = 1;
Defensive patterns
Strategy: validation
Validate before calling
if (isShardedTable(table) && !whereClauseContains(shardColumn)) {
addShardKeyCondition(sql, shardColumn, value); // or set a datanode hint
} Try / catch
try { routeSelect(sql); } catch (SQLNonTransientException e) { if (e.getMessage().contains("find no Route")) { routeWithHintOrFullScan(sql); } else throw e; } Prevention
- Always include the sharding key in WHERE clauses of SELECTs
- Configure a fallback (global table / route-all algorithm) for keyless queries
- Add query linting in the app to reject shard-key-less queries early
- Use HintManager/datanode hints for intentional cross-shard queries
When it happens
Trigger: A SELECT on a sharding table whose WHERE clause omits the partition/sharding column (and no default route or global table applies), so calcNode / tryRoute produces zero RouteResultsetNodes.
Common situations: Queries like `SELECT * FROM orders WHERE status=1` on a table sharded by customer_id; ORMs dropping the sharding key from generated SQL; queries with only non-sharding conditions or functions the router cannot evaluate.
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
- find no Route:
- "multi table related update not supported,tables:" +…
- can't find any valid datanode : -> ->
- multi table related update not supported,tables:
- global table is not supported in multi table related update
AI-assisted analysis of MyCATApache/Mycat-Server@65f8d8beb7 (2026-09-11).
Data as JSON: /api/errors/675bd271d1efa5c4.
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)