{"record":{"id":"fa037f0c6ca0b60f","repo":"MyCATApache/Mycat-Server","slug":"can-t-find-hint-datanode-hintsqlvalue-fa037f","errorCode":null,"errorMessage":"\"can't find hint datanode:\" + hintSQLValue","messagePattern":"\"can't find hint datanode:\" \\+ hintSQLValue","errorType":"exception","errorClass":"SQLNonTransientException","httpStatus":null,"severity":"error","filePath":"src/main/java/io/mycat/route/handler/HintDataNodeHandler.java","lineNumber":51,"sourceCode":"\t@Override\n\tpublic RouteResultset route(SystemConfig sysConfig, SchemaConfig schema, int sqlType, String realSQL,\n\t\t\tString charset, ServerConnection sc, LayerCachePool cachePool, String hintSQLValue,int hintSqlType, Map hintMap)\n\t\t\t\t\tthrows SQLNonTransientException {\n\t\t\n\t\tString stmt = realSQL;\n\t\t\n\t\tif (LOGGER.isDebugEnabled()) {\n\t\t\tLOGGER.debug(\"route datanode sql hint from \" + stmt);\n\t\t}\n\t\t\n\t\tRouteResultset rrs = new RouteResultset(stmt, sqlType);\t\t\n\t\tPhysicalDBNode dataNode = MycatServer.getInstance().getConfig().getDataNodes().get(hintSQLValue);\n\t\tif (dataNode != null) {\t\t\t\n\t\t\trrs = RouterUtil.routeToSingleNode(rrs, dataNode.getName(), stmt);\n\t\t} else {\n\t\t\tString msg = \"can't find hint datanode:\" + hintSQLValue;\n\t\t\tLOGGER.warn(msg);\n\t\t\tthrow new SQLNonTransientException(msg);\n\t\t}\n\n\t\t// 处理导入参数初始化\n\t\tif(rrs.getSqlType() == ServerParse.LOAD_DATA_INFILE_SQL){\n\t\t\tLOGGER.info(\"load data use annotation datanode\");\n\t\t\trrs.getNodes()[0].setLoadData(parseLoadDataPram(stmt , charset));\n\t\t}\n\t\t\n\t\treturn rrs;\n\t}\n\n\t// 初始化导入参数\n\tprivate LoadData parseLoadDataPram(String sql , String connectionCharset)\n\t{\n\t\tSQLStatementParser parser = new MycatStatementParser(sql);\n\t\tMySqlLoadDataInFileStatement statement = (MySqlLoadDataInFileStatement) parser.parseStatement();\n\n\t\tLoadData loadData = new LoadData();","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/MyCATApache/Mycat-Server/blob/65f8d8beb752f935752f2a0eec0ab017facab9ef/src/main/java/io/mycat/route/handler/HintDataNodeHandler.java#L33-L69","documentation":"The /*datanode=...*/ hint routes a statement to one specific data node. HintDataNodeHandler looks up hintSQLValue in MycatServer's configured dataNodes map; if no data node with that name exists, it throws SQLNonTransientException because the hinted route cannot be resolved.","triggerScenarios":"Sending a hint like `/* datanode=dn2 */ SELECT ...` (or HintManager.useDataNode(...)) where 'dn2' is not a <dataNode> name in Mycat's config, or the config was reloaded/renamed so the name no longer exists.","commonSituations":"Typo in the hint value; dataNode renamed in schema.xml after application code/SQL was already deployed; hint copied from another environment with different node names.","solutions":["Fix the hint value to match an existing <dataNode name=\"...\"> in schema.xml (check exact spelling/case)","List available nodes (config dump / show @@datanode) and use one of those names","If the config changed, update application code or hint-emitting middleware to the new data node names"],"exampleFix":"-- before\n/*datanode=dn_2*/ SELECT * FROM t_user WHERE id=1;\n-- after (matches schema.xml <dataNode name=\"dn2\">)\n/*datanode=dn2*/ SELECT * FROM t_user WHERE id=1;","handlingStrategy":"validation","validationCode":"Set<String> valid = mycatConfig.getDataNodes().keySet();\nif (!valid.contains(hintValue)) throw new IllegalArgumentException(\"unknown datanode: \" + hintValue);","typeGuard":"if (hintValue != null && MycatServer.getInstance().getConfig().getDataNodes().containsKey(hintValue)) { ... }","tryCatchPattern":"try { queryWithHint(hintValue, sql); } catch (SQLNonTransientException e) { if (e.getMessage().startsWith(\"can't find hint datanode\")) { refreshHintTargets(); } else throw e; }","preventionTips":["Centralize datanode names in app config rather than hard-coding hints","Validate hints against show @@datanode after each Mycat config reload","Use the same node-naming convention across environments","Avoid renaming data nodes without an app-config migration"],"tags":["mysql","routing","hint","datanode"],"backgroundTag":"resource-not-found","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"}