{"record":{"id":"7951aaf2983ace42","repo":"MyCATApache/Mycat-Server","slug":"table-tablename-duplicated","errorCode":null,"errorMessage":"table ${tableName} duplicated!","messagePattern":"table (.+?) duplicated!","errorType":"exception","errorClass":"ConfigException","httpStatus":null,"severity":"error","filePath":"src/main/java/io/mycat/config/loader/xml/XMLSchemaLoader.java","lineNumber":430,"sourceCode":"                        ruleRequired, null, false, null, null, subTables, fetchStoreNodeByJdbc);\n                //因为需要等待TableConfig构造完毕才可以拿到dataNode节点数量,所以Rule构造延后到此处 @cjw\n                if ((tableRuleConfig != null) && (tableRuleConfig.getRule().getRuleAlgorithm() instanceof TableRuleAware)) {\n                    AbstractPartitionAlgorithm newRuleAlgorithm = tableRuleConfig.getRule().getRuleAlgorithm();\n                    ((TableRuleAware)newRuleAlgorithm).setTableConfig(table);\n                    newRuleAlgorithm.init();\n                }\n                checkDataNodeExists(table.getDataNodes());\n                // 检查分片表分片规则配置是否合法\n                if (table.getRule() != null) {\n                    checkRuleSuitTable(table);\n                }\n\n                if (distTableDns) {\n                    distributeDataNodes(table.getDataNodes());\n                }\n                //检查去重\n                if (tables.containsKey(table.getName())) {\n                    throw new ConfigException(\"table \" + tableName + \" duplicated!\");\n                }\n                //放入map\n                tables.put(table.getName(), table);\n            }\n            //只有tableName配置的是单个表（没有逗号）的时候才能有子表\n            if (tableNames.length == 1) {\n                TableConfig table = tables.get(tableNames[0]);\n                // process child tables\n                processChildTables(tables, table, dataNode, tableElement);\n            }\n        }\n    }\n\n    private String getNewRuleName(String schemaName, String tableName, String name) {\n        return name + \"_\" + schemaName + \"_\" + tableName;\n    }\n\n    /**","sourceCodeStart":412,"sourceCodeEnd":448,"githubUrl":"https://github.com/MyCATApache/Mycat-Server/blob/65f8d8beb752f935752f2a0eec0ab017facab9ef/src/main/java/io/mycat/config/loader/xml/XMLSchemaLoader.java#L412-L448","documentation":"Thrown by XMLSchemaLoader.loadTable when two tables resolve to the same logical name in the same schema. The tables map is keyed by table name; inserting a duplicate would silently overwrite config, so Mycat rejects the schema at load time.","triggerScenarios":"A <table name=\"a,b\"> with comma-separated names where one name is also declared by another <table> element; or the same table name declared twice within one <schema>.","commonSituations":"Comma-expanded table names colliding with an existing explicit <table> entry; merging schema.xml fragments that both define the same table; copy-paste duplication.","solutions":["Rename one of the duplicate tables in schema.xml","Remove the redundant <table> declaration","Check comma-separated name lists for names already defined elsewhere in the schema"],"exampleFix":"// before (schema.xml)\n<table name=\"t1,t2\" dataNode=\"dn1\" />\n<table name=\"t2\" dataNode=\"dn2\" />\n// after\n<table name=\"t1\" dataNode=\"dn1\" />\n<table name=\"t2\" dataNode=\"dn2\" />","handlingStrategy":"validation","validationCode":"// detect duplicate table names (including comma-expanded lists) before load\nSet<String> seen = new HashSet<>();\nfor (Element t : schemaTables(\"schema.xml\")) {\n    for (String n : t.getAttribute(\"name\").split(\",\")) {\n        if (!seen.add(n.trim()))\n            throw new IllegalStateException(\"Duplicate table: \" + n);\n    }\n}","typeGuard":null,"tryCatchPattern":"try {\n    configLoader.load();\n} catch (ConfigException e) {\n    if (e.getMessage().contains(\"duplicated!\")) {\n        String name = e.getMessage().replace(\"table \", \"\").replace(\" duplicated!\", \"\");\n        log.error(\"Table declared more than once in schema.xml: \" + name, e);\n    }\n    throw e;\n}","preventionTips":["After editing comma-separated table name lists, re-check for collisions with existing tables","Maintain one canonical source for table declarations; avoid merging schema fragments blindly","Add a config lint step that flags duplicate table names in CI"],"tags":["config","xml","duplicate-key"],"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"}