{"record":{"id":"ea47558130c825b1","repo":"MyCATApache/Mycat-Server","slug":"table-table-getname-duplicated","errorCode":null,"errorMessage":"table ${table.getName()} duplicated!","messagePattern":"table (.+?) duplicated!","errorType":"exception","errorClass":"ConfigException","httpStatus":null,"severity":"error","filePath":"src/main/java/io/mycat/config/loader/xml/XMLSchemaLoader.java","lineNumber":550,"sourceCode":"                autoIncrement = Boolean.parseBoolean(childTbElement.getAttribute(\"autoIncrement\"));\n            }\n            boolean needAddLimit = true;\n            if (childTbElement.hasAttribute(\"needAddLimit\")) {\n                needAddLimit = Boolean.parseBoolean(childTbElement.getAttribute(\"needAddLimit\"));\n            }\n\n            String subTables = childTbElement.getAttribute(\"subTables\");\n            //子表join键，和对应的parent的键，父子表通过这个关联\n            String joinKey = childTbElement.getAttribute(\"joinKey\").toUpperCase();\n            String parentKey = childTbElement.getAttribute(\"parentKey\").toUpperCase();\n            TableConfig table = new TableConfig(cdTbName, primaryKey,\n                    autoIncrement, needAddLimit,\n                    TableConfig.TYPE_GLOBAL_DEFAULT, dataNodes,\n                    getDbType(dataNodes), null, false, parentTable, true,\n                    joinKey, parentKey, subTables, false);\n\n            if (tables.containsKey(table.getName())) {\n                throw new ConfigException(\"table \" + table.getName() + \" duplicated!\");\n            }\n            tables.put(table.getName(), table);\n            //对于子表的子表，递归处理\n            processChildTables(tables, table, dataNodes, childTbElement);\n        }\n    }\n\n    private void checkDataNodeExists(Collection<String> nodes) {\n        if (nodes == null || nodes.size() < 1) {\n            return;\n        }\n        for (String node : nodes) {\n            if (!dataNodes.containsKey(node)) {\n                throw new ConfigException(\"dataNode '\" + node + \"' is not found!\");\n            }\n        }\n    }\n","sourceCodeStart":532,"sourceCodeEnd":568,"githubUrl":"https://github.com/MyCATApache/Mycat-Server/blob/65f8d8beb752f935752f2a0eec0ab017facab9ef/src/main/java/io/mycat/config/loader/xml/XMLSchemaLoader.java#L532-L568","documentation":"Thrown by XMLSchemaLoader's child-table processing (processChildTables, called recursively from the constructor) when a child <table> in a parent/child (ER) sharding setup has the same name as a table already registered. Child tables are also keyed by name in the tables map, so duplicates are rejected at load.","triggerScenarios":"A nested <childTable name=\"...\"> (or recursive child-of-child) whose name equals a table already present in the tables map, including a child table colliding with its parent or sibling.","commonSituations":"Copy-pasted childTable blocks with the same name; child table name accidentally matching a normal table; deep sub-table recursion reusing names.","solutions":["Give the childTable a unique name distinct from all other tables and child tables","Remove the duplicate childTable element from schema.xml","Verify the parent/child table hierarchy has unique names at every level"],"exampleFix":"// before (schema.xml)\n<childTable name=\"orders\" joinKey=\"cid\" parentKey=\"id\" />\n// after\n<childTable name=\"order_items\" joinKey=\"cid\" parentKey=\"id\" />","handlingStrategy":"validation","validationCode":"// collect parent + childTable names and ensure uniqueness before load\nSet<String> names = new HashSet<>();\nfor (Element t : schemaTables(\"schema.xml\")) {\n    addAllTableNames(names, t); // includes nested <childTable> recursively\n}\nif (names.size() != totalCount) throw new IllegalStateException(\"Duplicate child table name\");","typeGuard":null,"tryCatchPattern":"try {\n    configLoader.load();\n} catch (ConfigException e) {\n    if (e.getMessage().contains(\"duplicated!\")) {\n        log.error(\"Child table name collides with an existing table/childTable in schema.xml\", e);\n    }\n    throw e;\n}","preventionTips":["Name child tables with distinct suffixes (e.g. order_item vs order) to avoid collisions","Walk the childTable tree after edits to confirm unique names at each level","Never reuse a parent's name for a child table"],"tags":["config","xml","duplicate-key","child-table"],"backgroundTag":"conflicting-config-options","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"}