{"record":{"id":"e3f69e1175d1f674","repo":"MyCATApache/Mycat-Server","slug":"selfcheck-schema-dbnode-is-empty","errorCode":null,"errorMessage":"SelfCheck### schema dbnode is empty!","messagePattern":"SelfCheck### schema dbnode is empty!","errorType":"exception","errorClass":"io.mycat.config.ConfigException","httpStatus":null,"severity":"error","filePath":"src/main/java/io/mycat/config/ConfigInitializer.java","lineNumber":162,"sourceCode":"\t\t\t\t}\n\t\t\t}\n\t\t}\t\n\t\t\n\t\t\n\t\t// schema 配置检测\t\t\n\t\tfor (SchemaConfig sc : schemas.values()) {\n\t\t\tif (null == sc) {\n\t\t\t\tthrow new ConfigException(\"SelfCheck### schema all node is empty!\");\n\t\t\t\t\n\t\t\t} else {\t\t\t\t\n\t\t\t\t// check dataNode / dataHost 节点\n\t\t\t\tif ( this.dataNodes != null &&  this.dataHosts != null  ) {\t\t\t\t\t\n\t\t\t\t\tSet<String> dataNodeNames = sc.getAllDataNodes();\n\t\t\t\t\tfor(String dataNodeName: dataNodeNames) {\n\t\t\t\t\t\t\n\t\t\t\t\t\tPhysicalDBNode node = this.dataNodes.get(dataNodeName);\n\t\t\t\t\t\tif ( node == null ) {\n\t\t\t\t\t\t\tthrow new ConfigException(\"SelfCheck### schema dbnode is empty!\");\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\t\n\t\t\n\t}\n\t\n\tpublic void testConnection() {\n\t\t\n\t\t// 实际链路的连接测试\t\t\n\t\tif ( this.dataNodes != null &&  this.dataHosts != null  ) {\n\t\t\t\n\t\t\tMap<String, Boolean> map = new HashMap<String, Boolean>();\n\t\t\t\n\t\t\tfor(PhysicalDBNode dataNode: dataNodes.values() ) {\n\t\t\t\t\n\t\t\t\tString database = dataNode.getDatabase();\t\t","sourceCodeStart":144,"sourceCodeEnd":180,"githubUrl":"https://github.com/MyCATApache/Mycat-Server/blob/65f8d8beb752f935752f2a0eec0ab017facab9ef/src/main/java/io/mycat/config/ConfigInitializer.java#L144-L180","documentation":"Thrown by ConfigInitializer.selfChecking0 when a schema references a dataNode name that does not exist in the loaded dataNodes map (dataNode/dbnode definitions from schema.xml). MyCat validates every dataNode referenced by each schema resolves to a defined PhysicalDBNode; an unresolvable reference means the schema's data cannot be routed, so startup fails with ConfigException.","triggerScenarios":"ConfigInitializer constructor where sc.getAllDataNodes() returns a name absent from this.dataNodes — i.e. a <schema> or its tables reference a dataNode not defined in schema.xml, or the name is misspelled/case-mismatched (only checked when dataNodes and dataHosts are both non-null).","commonSituations":"dataNode attribute in <schema name=\"...\" dataNode=\"dn1\"> with no <dataNode name=\"dn1\"> definition; typos in table-level dataNode attributes; removing a dataNode definition while schemas still reference it; case mismatch (DN1 vs dn1).","solutions":["Read the schema name from the failed startup context and list its dataNode references in schema.xml.","Ensure each referenced name has a matching <dataNode name=\"...\" dataHost=\"...\" database=\"...\"> definition.","Fix typos/case mismatches between schema references and dataNode definitions.","Verify the referenced dataHost also exists in the dataHosts definitions."],"exampleFix":"// before (schema.xml)\n<schema name=\"testdb\" dataNode=\"dn2\" />\n// after (matching dataNode exists)\n<dataNode name=\"dn2\" dataHost=\"host1\" database=\"db2\" />\n<schema name=\"testdb\" dataNode=\"dn2\" />","handlingStrategy":"validation","validationCode":"// Verify every schema dataNode reference resolves before init\nfor (SchemaConfig sc : schemas.values()) {\n    for (String dn : sc.getAllDataNodes()) {\n        if (!dataNodes.containsKey(dn)) {\n            throw new IllegalArgumentException(\"schema \" + sc.getName() + \" references missing dataNode \" + dn);\n        }\n    }\n}","typeGuard":null,"tryCatchPattern":"try {\n    new ConfigInitializer(...);\n} catch (ConfigException e) {\n    if (e.getMessage().contains(\"schema dbnode is empty\")) {\n        LOGGER.error(\"Schema references undefined dataNode: {}\", e.getMessage());\n        // roll back schema.xml change\n    } else { throw e; }\n}","preventionTips":["Keep schema dataNode attributes and <dataNode> definitions in sync; review both files in one change.","Use consistent lowercase naming for dataNodes to avoid case-mismatch bugs.","Run an XML-lint/reference checker on schema.xml in CI.","When deleting a dataNode, first grep schema.xml for remaining references."],"tags":["config","startup","mycat","data-node"],"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"}