MyCATApache/Mycat-Server · error · ConfigException
node name duplicated
Error message
node name duplicated :${name} What it means
ClusterConfig.loadNode parses <node> elements from the Mycat cluster XML (cluster.xml). Each node must have a unique 'name' attribute; if a second element has the same name it throws ConfigException 'node name duplicated'. This prevents ambiguous node definitions in the cluster model.
Solutions
- Open cluster.xml and find all <node> elements sharing the same name attribute.
- Rename one node to a unique name (e.g. nodeM1, nodeM2) and update any <group nodeList=...> references to match.
- Search the file for 'node name=' and de-duplicate before restarting Mycat.
- If config is generated, fix the generator/template to enforce unique names.
Example fix
<!-- before --> <node name="nodeM1" host="10.0.0.1" ... /> <node name="nodeM1" host="10.0.0.2" ... /> <!-- after --> <node name="nodeM1" host="10.0.0.1" ... /> <node name="nodeM2" host="10.0.0.2" ... />
Defensive patterns
Strategy: validation
Validate before calling
// Before startup, check for duplicate node names in cluster.xml
import javax.xml.xpath.*;
var doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse("cluster.xml");
var nodes = XPathFactory.newInstance().newXPath().evaluate("//node/@name", doc, XPathConstants.NODESET);
var seen = new java.util.HashSet<String>();
for (int i = 0; i < nodes.getLength(); i++) {
String n = nodes.item(i).getNodeValue().trim();
if (!seen.add(n)) throw new IllegalStateException("duplicate node name: " + n);
} Try / catch
try { new ClusterConfig(); } catch (ConfigException e) { if (e.getMessage().startsWith("node name duplicated")) { log.error("Fix duplicate <node name> in cluster.xml"); } throw e; } Prevention
- Lint cluster.xml for duplicate names in CI
- Avoid copy-pasting node blocks without renaming
- Keep node names in a shared naming convention
- Review merge conflicts in cluster.xml carefully
When it happens
Trigger: XML contains two or more <node name="X" ...> elements with the same trimmed name; thrown at ClusterConfig.java:73 while loadNode iterates the node list.
Common situations: Copy-paste of a <node> block when adding a second host without renaming it, merge conflicts in cluster.xml that duplicated a block, or automated config generation emitting duplicates.
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
- group duplicated
- group should contain 'nodeList'
- host empty in node
- node host duplicated
- weight should be > 0 in host
AI-assisted analysis of MyCATApache/Mycat-Server@65f8d8beb7 (2026-09-11).
Data as JSON: /api/errors/dcdfa346af7a80ad.
Report an issue: GitHub.
Appendix: source
Thrown at src/main/java/io/mycat/config/model/ClusterConfig.java:73
public Map<String, MycatNodeConfig> getNodes() {
return nodes;
}
public Map<String, List<String>> getGroups() {
return groups;
}
private static Map<String, MycatNodeConfig> loadNode(Element root, int port) {
Map<String, MycatNodeConfig> nodes = new HashMap<String, MycatNodeConfig>();
NodeList list = root.getElementsByTagName("node");
Set<String> hostSet = new HashSet<String>();
for (int i = 0, n = list.getLength(); i < n; i++) {
Node node = list.item(i);
if (node instanceof Element) {
Element element = (Element) node;
String name = element.getAttribute("name").trim();
if (nodes.containsKey(name)) {
throw new ConfigException("node name duplicated :" + name);
}
Map<String, Object> props = ConfigUtil.loadElements(element);
String host = (String) props.get("host");
if (null == host || "".equals(host)) {
throw new ConfigException("host empty in node: " + name);
}
if (hostSet.contains(host)) {
throw new ConfigException("node host duplicated :" + host);
}
String wei = (String) props.get("weight");
if (null == wei || "".equals(wei)) {
throw new ConfigException("weight should not be null in host:" + host);
}
int weight = Integer.parseInt(wei);
if (weight <= 0) {
throw new ConfigException("weight should be > 0 in host:" + host + " weight:" + weight);View on GitHub (pinned to 65f8d8beb7)