{"record":{"id":"63c28fbad1b807ba","repo":"MyCATApache/Mycat-Server","slug":"selfcheck-schema-schema-refered-by-user-use","errorCode":null,"errorMessage":"SelfCheck###  schema {schema} refered by user {userName} is not exist!","messagePattern":"SelfCheck###  schema (.+?) refered by user (.+?) is not exist!","errorType":"exception","errorClass":"io.mycat.config.ConfigException","httpStatus":null,"severity":"error","filePath":"src/main/java/io/mycat/config/ConfigInitializer.java","lineNumber":142,"sourceCode":"\t\tif (users == null || users.isEmpty()) {\n\t\t\tthrow new ConfigException(\"SelfCheck### user all node is empty!\");\n\t\t\t\n\t\t} else {\n\t\t\t\n\t\t\tfor (UserConfig uc : users.values()) {\n\t\t\t\tif (uc == null) {\n\t\t\t\t\tthrow new ConfigException(\"SelfCheck### users node within the item is empty!\");\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tSet<String> authSchemas = uc.getSchemas();\n\t\t\t\tif (authSchemas == null) {\n\t\t\t\t\tthrow new ConfigException(\"SelfCheck### user \" + uc.getName() + \"refered schemas is empty!\");\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tfor (String schema : authSchemas) {\n\t\t\t\t\tif ( !schemas.containsKey(schema) ) {\n\t\t\t\t\t\tString errMsg = \"SelfCheck###  schema \" + schema + \" refered by user \" + uc.getName() + \" is not exist!\";\n\t\t\t\t\t\tthrow new ConfigException(errMsg);\n\t\t\t\t\t}\n\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);","sourceCodeStart":124,"sourceCodeEnd":160,"githubUrl":"https://github.com/MyCATApache/Mycat-Server/blob/65f8d8beb752f935752f2a0eec0ab017facab9ef/src/main/java/io/mycat/config/ConfigInitializer.java#L124-L160","documentation":"Thrown by ConfigInitializer.selfChecking0 during startup self-check when a user's schemas set contains a schema name that does not exist in the loaded schema.xml configuration. MyCat validates that every schema referenced by a user resolves to a defined <schema> node; otherwise authorization and routing would break, so it fails fast with ConfigException.","triggerScenarios":"ConfigInitializer constructor with a server.xml user whose schemas property lists a name not present in the schemas map loaded from schema.xml (typo, renamed or removed schema, case mismatch).","commonSituations":"Renaming a schema in schema.xml without updating server.xml users; deleting a schema that is still referenced; case sensitivity mismatch (TESTDB vs testdb); leftover users from copy-pasted example configs pointing at nonexistent schemas.","solutions":["Open server.xml and find the user whose schemas property lists the missing schema name (named in the message).","Fix the schema name in server.xml to exactly match a <schema name=\"...\"> in schema.xml, or create the missing schema in schema.xml.","Check for case mismatches between the two files.","Reload/restart MyCat and confirm the self-check passes."],"exampleFix":"// before (server.xml)\n<property name=\"schemas\">testdb2</property>\n// after (schema.xml has <schema name=\"testdb\">)\n<property name=\"schemas\">testdb</property>","handlingStrategy":"validation","validationCode":"// Validate every user schema reference exists before init\nfor (UserConfig uc : users.values()) {\n    for (String s : uc.getSchemas()) {\n        if (!schemas.containsKey(s)) {\n            throw new IllegalArgumentException(\"schema \" + s + \" referenced by user \" + uc.getName() + \" not found\");\n        }\n    }\n}","typeGuard":null,"tryCatchPattern":"try {\n    initializer = new ConfigInitializer(...);\n} catch (ConfigException e) {\n    if (e.getMessage().contains(\"is not exist\")) {\n        LOGGER.error(\"Dangling user->schema reference: {}\", e.getMessage());\n        // abort deploy or roll back config\n    } else { throw e; }\n}","preventionTips":["Use a single source of truth script that checks user schemas against schema.xml schema names.","Watch case sensitivity: schema names are matched exactly.","When renaming a schema, grep server.xml for old references.","Run mycat's self-check in a staging environment before production reloads."],"tags":["config","startup","mycat","reference-validation"],"backgroundTag":"schema-validation-failed","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"}