{"record":{"id":"67950e8efc26fbee","repo":"MyCATApache/Mycat-Server","slug":"weight-should-be-0-in-host-host-weight-weig","errorCode":null,"errorMessage":"weight should be > 0 in host:${host} weight:${weight}","messagePattern":"weight should be > 0 in host:(.+?) weight:(.+?)","errorType":"exception","errorClass":"ConfigException","httpStatus":null,"severity":"error","filePath":"src/main/java/io/mycat/config/model/ClusterConfig.java","lineNumber":91,"sourceCode":"                    throw new ConfigException(\"node name duplicated :\" + name);\n                }\n\n                Map<String, Object> props = ConfigUtil.loadElements(element);\n                String host = (String) props.get(\"host\");\n                if (null == host || \"\".equals(host)) {\n                    throw new ConfigException(\"host empty in node: \" + name);\n                }\n                if (hostSet.contains(host)) {\n                    throw new ConfigException(\"node host duplicated :\" + host);\n                }\n\n                String wei = (String) props.get(\"weight\");\n                if (null == wei || \"\".equals(wei)) {\n                    throw new ConfigException(\"weight should not be null in host:\" + host);\n                }\n                int weight = Integer.parseInt(wei);\n                if (weight <= 0) {\n                    throw new ConfigException(\"weight should be > 0 in host:\" + host + \" weight:\" + weight);\n                }\n\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();","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/MyCATApache/Mycat-Server/blob/65f8d8beb752f935752f2a0eec0ab017facab9ef/src/main/java/io/mycat/config/model/ClusterConfig.java#L73-L109","documentation":"After parsing the weight value with Integer.parseInt, loadNode requires it to be strictly positive; weight <= 0 throws ConfigException 'weight should be > 0 in host: <host> weight: <weight>'. Zero or negative weights would break weighted load balancing.","triggerScenarios":"A node's weight property parses to an integer <= 0 (e.g. weight=0 or weight=-1); thrown at ClusterConfig.java:91.","commonSituations":"Setting weight=0 to 'disable' a node (use removal or group membership instead), copy-pasted negative value, or a typo like weight=\"-5\".","solutions":["Change the weight property to a positive integer (>= 1).","If you meant to exclude a node, remove it from the <group nodeList> instead of setting weight 0.","Validate all weight values are positive integers before deployment.","Restart Mycat after editing cluster.xml."],"exampleFix":"<!-- before -->\n<property name=\"weight\">0</property>\n<!-- after -->\n<property name=\"weight\">1</property>","handlingStrategy":"validation","validationCode":"String w = propOf(nodeEl, \"weight\");\nint weight = Integer.parseInt(w.trim());\nif (weight <= 0) throw new IllegalStateException(\"weight must be > 0 for node \" + nodeEl.getAttribute(\"name\"));","typeGuard":null,"tryCatchPattern":"try { new ClusterConfig(); } catch (ConfigException e) { if (e.getMessage().startsWith(\"weight should be > 0\")) { log.error(\"Set a positive integer weight in cluster.xml\"); } throw e; }","preventionTips":["Never use weight=0 to disable a node; remove it from the group instead","Keep weights positive integers matching machine capacity","Check for typos producing negative values","Lint numeric fields in cluster.xml"],"tags":["xml","config","invalid-value","load-balancing","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"}