{"record":{"id":"dd90606a270f0a47","repo":"MyCATApache/Mycat-Server","slug":"datahost-not-exists-datahost","errorCode":null,"errorMessage":"dataHost not exists {dataHost}","messagePattern":"dataHost not exists (.+?)","errorType":"exception","errorClass":"io.mycat.config.ConfigException","httpStatus":null,"severity":"critical","filePath":"src/main/java/io/mycat/config/ConfigInitializer.java","lineNumber":333,"sourceCode":"\t\t\tPhysicalDatasource[] readSources = createDataSource(conf, name,\n\t\t\t\t\tdbType, dbDriver, entry.getValue(), true);\n\t\t\treadSourcesMap.put(entry.getKey(), readSources);\n\t\t}\n\t\tPhysicalDBPool pool = new PhysicalDBPool(conf.getName(), conf,\n\t\t\t\twriteSources, readSourcesMap, conf.getBalance(),\n\t\t\t\tconf.getWriteType());\n\t\tpool.setSlaveIDs(conf.getSlaveIDs());\n\t\treturn pool;\n\t}\n\n\tprivate Map<String, PhysicalDBNode> initDataNodes(ConfigLoader configLoader) {\n\t\tMap<String, DataNodeConfig> nodeConfs = configLoader.getDataNodes();\n\t\tMap<String, PhysicalDBNode> nodes = new HashMap<String, PhysicalDBNode>(\n\t\t\t\tnodeConfs.size());\n\t\tfor (DataNodeConfig conf : nodeConfs.values()) {\n\t\t\tPhysicalDBPool pool = this.dataHosts.get(conf.getDataHost());\n\t\t\tif (pool == null) {\n\t\t\t\tthrow new ConfigException(\"dataHost not exists \"\n\t\t\t\t\t\t+ conf.getDataHost());\n\n\t\t\t}\n\t\t\tPhysicalDBNode dataNode = new PhysicalDBNode(conf.getName(),\n\t\t\t\t\tconf.getDatabase(), pool);\n\t\t\tnodes.put(dataNode.getName(), dataNode);\n\t\t}\n\t\treturn nodes;\n\t}\n\n}\n","sourceCodeStart":315,"sourceCodeEnd":345,"githubUrl":"https://github.com/MyCATApache/Mycat-Server/blob/65f8d8beb752f935752f2a0eec0ab017facab9ef/src/main/java/io/mycat/config/ConfigInitializer.java#L315-L345","documentation":"During initDataNodes, each dataNode references a dataHost by name; ConfigInitializer looks the host up in the already-parsed dataHosts map and throws ConfigException('dataHost not exists ...') when the reference cannot be resolved.","triggerScenarios":"A <dataNode> in schema.xml sets a dataHost attribute that has no matching <dataHost> name (typo, missing dataHost block, or dataHost defined in a file not loaded).","commonSituations":"Copy-pasting dataNode definitions without copying the corresponding dataHost; renaming a dataHost but not updating dataNode references; XML config split across files with only one loaded.","solutions":["Add or fix a <dataHost name=\"...\"> entry whose name exactly matches the dataNode's dataHost attribute","Check for typos/case differences between dataNode.dataHost and dataHost.name","If config is split across files, ensure the dataHost is actually loaded by the ConfigLoader"],"exampleFix":"// before (schema.xml)\n<dataNode name=\"dn1\" dataHost=\"host1\" database=\"db\" />\n// after (add matching host or fix reference)\n<dataHost name=\"host1\"> ... </dataHost>\n<dataNode name=\"dn1\" dataHost=\"host1\" database=\"db\" />","handlingStrategy":"validation","validationCode":"Set<String> hostNames = dataHosts.keySet();\nfor (DataNodeConfig n : dataNodes) {\n    if (!hostNames.contains(n.getDataHost()))\n        throw new IllegalArgumentException(\"dataHost not exists: \" + n.getDataHost());\n}","typeGuard":null,"tryCatchPattern":"try {\n    initConfig();\n} catch (ConfigException e) {\n    if (e.getMessage().startsWith(\"dataHost not exists\")) {\n        // fix schema.xml reference before retrying startup\n    }\n}","preventionTips":["Keep dataHost names and dataNode references in one reviewed schema.xml section","Grep-validate every dataNode.dataHost attribute against declared dataHost names in CI","Avoid renaming dataHosts without a global search/replace across schema.xml"],"tags":["config","datanode","datahost","missing-reference"],"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"}