MyCATApache/Mycat-Server · error · ConfigException

group duplicated

Error message

group duplicated : ${groupName}

What it means

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.

Solutions

  1. Locate duplicated <group name="..."> elements in cluster.xml and rename one uniquely.
  2. Update references (e.g. hostGroup / group selection rules) to the renamed group.
  3. De-duplicate the file by searching for 'group name=' before restarting.
  4. Fix the config generator if it emits duplicate groups.

Example fix

<!-- before -->
<group name="group1" nodeList="nodeM1" />
<group name="group1" nodeList="nodeM2" />
<!-- after -->
<group name="group1" nodeList="nodeM1" />
<group name="group2" nodeList="nodeM2" />
Defensive patterns

Strategy: validation

Validate before calling

var groups = XPathFactory.newInstance().newXPath().evaluate("//group/@name", doc, XPathConstants.NODESET);
var seen = new java.util.HashSet<String>();
for (int i = 0; i < groups.getLength(); i++) {
  String g = groups.item(i).getNodeValue().trim();
  if (!seen.add(g)) throw new IllegalStateException("duplicate group name: " + g);
}

Try / catch

try { new ClusterConfig(); } catch (ConfigException e) { if (e.getMessage().startsWith("group duplicated")) { log.error("Rename duplicated <group name> in cluster.xml"); } throw e; }

Prevention

When it happens

Trigger: Two <group name="X" ...> elements appear in the XML (after trimming); thrown while loadGroup iterates the group list.

Common situations: 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.

Understand the failure class

Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.

Related errors


AI-assisted analysis of MyCATApache/Mycat-Server@65f8d8beb7 (2026-09-11). Data as JSON: /api/errors/f2dadc90fef7bd0d. Report an issue: GitHub.

Appendix: source

Thrown at src/main/java/io/mycat/config/model/ClusterConfig.java:111

                MycatNodeConfig conf = new MycatNodeConfig(name, host, port, weight);
                nodes.put(name, conf);
                hostSet.add(host);
            }
        }
        return nodes;
    }

    private static Map<String, List<String>> loadGroup(Element root, Map<String, MycatNodeConfig> nodes) {
        Map<String, List<String>> groups = new HashMap<String, List<String>>();
        NodeList list = root.getElementsByTagName("group");
        for (int i = 0, n = list.getLength(); i < n; i++) {
            Node node = list.item(i);
            if (node instanceof Element) {
                Element e = (Element) node;
                String groupName = e.getAttribute("name").trim();
                if (groups.containsKey(groupName)) {
                    throw new ConfigException("group duplicated : " + groupName);
                }

                Map<String, Object> props = ConfigUtil.loadElements(e);
                String value = (String) props.get("nodeList");
                if (null == value || "".equals(value)) {
                    throw new ConfigException("group should contain 'nodeList'");
                }

                String[] sList = SplitUtil.split(value, ',', true);

                if (null == sList || sList.length == 0) {
                    throw new ConfigException("group should contain 'nodeList'");
                }

                for (String s : sList) {
                    if (!nodes.containsKey(s)) {
                        throw new ConfigException("[ node :" + s + "] in [ group:" + groupName + "] doesn't exist!");
                    }

View on GitHub (pinned to 65f8d8beb7)