{"record":{"id":"675bd271d1efa5c4","repo":"MyCATApache/Mycat-Server","slug":"find-no-route-ctx-getsql","errorCode":null,"errorMessage":"\" find no Route:\" + ctx.getSql()","messagePattern":"\" find no Route:\" \\+ ctx\\.getSql\\(\\)","errorType":"exception","errorClass":"SQLNonTransientException","httpStatus":null,"severity":"error","filePath":"src/main/java/io/mycat/route/parser/druid/impl/DruidSelectParser.java","lineNumber":618,"sourceCode":"\t\t\t\tfor(String key: ctx.getTableAliasMap().keySet()){\r\n\t\t\t\t\tTableConfig tb_config = schema.getTables().get(key.toUpperCase());\r\n\t\t\t\t\tif(tb_config!=null){\r\n\t\t\t\t\t\tString table_name = ctx.getTableAliasMap().get(key);\r\n\t\t\t\t\t\tfor(String dataNode:tb_config.getDataNodes()){\r\n\t\t\t\t\t\t\tif(tb_config.getDataNodes().size()==1 || table_name.startsWith(dataNode+'.')){\r\n\t\t\t\t\t\t\t\trrs = RouterUtil.routeToSingleNode(rrs, dataNode, ctx.getSql());\r\n\t\t\t\t\t\t\t\trrs.setFinishedRoute(true);\r\n\t\t\t\t\t\t\t\treturn;\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}\r\n\t\t\t}\r\n\t\t\t//end@byron\r\n\r\n\t\t\tString msg = \" find no Route:\" + ctx.getSql();\r\n\t\t\tLOGGER.warn(msg);\r\n\t\t\tthrow new SQLNonTransientException(msg);\r\n\t\t}\r\n\r\n\t\tRouteResultsetNode[] nodes = new RouteResultsetNode[nodeSet.size()];\r\n\t\tint i = 0;\r\n\t\tfor (Iterator<RouteResultsetNode> iterator = nodeSet.iterator(); iterator.hasNext();) {\r\n\t\t\tnodes[i] = (RouteResultsetNode) iterator.next();\r\n\t\t\ti++;\r\n\r\n\t\t}\r\n\r\n\t\trrs.setNodes(nodes);\r\n\t\trrs.setFinishedRoute(true);\r\n\t}\r\n\r\n\r\n\tprotected String getCurentDbType()\r\n\t{\r\n\t\treturn JdbcConstants.MYSQL.name();\r","sourceCodeStart":600,"sourceCodeEnd":636,"githubUrl":"https://github.com/MyCATApache/Mycat-Server/blob/65f8d8beb752f935752f2a0eec0ab017facab9ef/src/main/java/io/mycat/route/parser/druid/impl/DruidSelectParser.java#L600-L636","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"-- before\nSELECT * FROM orders WHERE status = 1;\n-- after (orders sharded by customer_id)\nSELECT * FROM orders WHERE customer_id = 123 AND status = 1;","handlingStrategy":"validation","validationCode":"if (isShardedTable(table) && !whereClauseContains(shardColumn)) {\n    addShardKeyCondition(sql, shardColumn, value); // or set a datanode hint\n}","typeGuard":null,"tryCatchPattern":"try { routeSelect(sql); } catch (SQLNonTransientException e) { if (e.getMessage().contains(\"find no Route\")) { routeWithHintOrFullScan(sql); } else throw e; }","preventionTips":["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"],"tags":["mysql","routing","sharding","select"],"backgroundTag":"empty-result-set","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"}