{"record":{"id":"f2dadc90fef7bd0d","repo":"MyCATApache/Mycat-Server","slug":"group-duplicated-groupname","errorCode":null,"errorMessage":"group duplicated : ${groupName}","messagePattern":"group duplicated : (.+?)","errorType":"exception","errorClass":"ConfigException","httpStatus":null,"severity":"error","filePath":"src/main/java/io/mycat/config/model/ClusterConfig.java","lineNumber":111,"sourceCode":"\n                MycatNodeConfig conf = new MycatNodeConfig(name, host, port, weight);\n                nodes.put(name, conf);\n                hostSet.add(host);\n            }\n        }\n        return nodes;\n    }\n\n    private static Map<String, List<String>> loadGroup(Element root, Map<String, MycatNodeConfig> nodes) {\n        Map<String, List<String>> groups = new HashMap<String, List<String>>();\n        NodeList list = root.getElementsByTagName(\"group\");\n        for (int i = 0, n = list.getLength(); i < n; i++) {\n            Node node = list.item(i);\n            if (node instanceof Element) {\n                Element e = (Element) node;\n                String groupName = e.getAttribute(\"name\").trim();\n                if (groups.containsKey(groupName)) {\n                    throw new ConfigException(\"group duplicated : \" + groupName);\n                }\n\n                Map<String, Object> props = ConfigUtil.loadElements(e);\n                String value = (String) props.get(\"nodeList\");\n                if (null == value || \"\".equals(value)) {\n                    throw new ConfigException(\"group should contain 'nodeList'\");\n                }\n\n                String[] sList = SplitUtil.split(value, ',', true);\n\n                if (null == sList || sList.length == 0) {\n                    throw new ConfigException(\"group should contain 'nodeList'\");\n                }\n\n                for (String s : sList) {\n                    if (!nodes.containsKey(s)) {\n                        throw new ConfigException(\"[ node :\" + s + \"] in [ group:\" + groupName + \"] doesn't exist!\");\n                    }","sourceCodeStart":93,"sourceCodeEnd":129,"githubUrl":"https://github.com/MyCATApache/Mycat-Server/blob/65f8d8beb752f935752f2a0eec0ab017facab9ef/src/main/java/io/mycat/config/model/ClusterConfig.java#L93-L129","documentation":"ClusterConfig.loadGroup parses <group> elements in cluster.xml; each group must have a unique 'name' attribute. A repeated name throws ConfigException 'group duplicated : <groupName>' at ClusterConfig.java:111. Group names are keys in the groups map, so duplicates are rejected at load time.","triggerScenarios":"Two <group name=\"X\" ...> elements appear in the XML (after trimming); thrown while loadGroup iterates the group list.","commonSituations":"Copy-paste of a group block when creating another region/group without renaming, merge conflicts duplicating a block, or generated config emitting the same group twice.","solutions":["Locate duplicated <group name=\"...\"> elements in cluster.xml and rename one uniquely.","Update references (e.g. hostGroup / group selection rules) to the renamed group.","De-duplicate the file by searching for 'group name=' before restarting.","Fix the config generator if it emits duplicate groups."],"exampleFix":"<!-- before -->\n<group name=\"group1\" nodeList=\"nodeM1\" />\n<group name=\"group1\" nodeList=\"nodeM2\" />\n<!-- after -->\n<group name=\"group1\" nodeList=\"nodeM1\" />\n<group name=\"group2\" nodeList=\"nodeM2\" />","handlingStrategy":"validation","validationCode":"var groups = XPathFactory.newInstance().newXPath().evaluate(\"//group/@name\", doc, XPathConstants.NODESET);\nvar seen = new java.util.HashSet<String>();\nfor (int i = 0; i < groups.getLength(); i++) {\n  String g = groups.item(i).getNodeValue().trim();\n  if (!seen.add(g)) throw new IllegalStateException(\"duplicate group name: \" + g);\n}","typeGuard":null,"tryCatchPattern":"try { new ClusterConfig(); } catch (ConfigException e) { if (e.getMessage().startsWith(\"group duplicated\")) { log.error(\"Rename duplicated <group name> in cluster.xml\"); } throw e; }","preventionTips":["Name groups uniquely (group1, group2, ...) with a convention","Re-check the file after merge conflicts","De-duplicate generated config output","Lint for duplicate group names in CI"],"tags":["xml","config","duplicate-name","cluster","mycat"],"backgroundTag":"invalid-config-value","analyzedSha":"65f8d8beb752f935752f2a0eec0ab017facab9ef","analyzedAt":"2026-09-11T00:12:21.696Z","contentChangedAt":"2026-09-11T00:12:21.696Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}