{"record":{"id":"3a101845ea903e08","repo":"MyCATApache/Mycat-Server","slug":"illegal-table-conf-table-tableconf-getname","errorCode":null,"errorMessage":"Illegal table conf : table [ ${tableConf.getName()} ] rule function [ ${tableConf.getRule().getFunctionName()} ] partition size : ${...getPartitionNum()} > table datanode size : ${...size()}, please make sure table datanode size = function partition size","messagePattern":"Illegal table conf : table \\[ (.+?) \\] rule function \\[ (.+?) \\] partition size : (.+?) > table datanode size : (.+?), please make sure table datanode size = function partition size","errorType":"exception","errorClass":"ConfigException","httpStatus":null,"severity":"error","filePath":"src/main/java/io/mycat/config/loader/xml/XMLSchemaLoader.java","lineNumber":593,"sourceCode":"     * }\n     * <br>\n     * 分片算法如下:<br>\n     * {@code\n     * <function name=\"mod-long\" class=\"io.mycat.route.function.PartitionByMod\">\n     * <!-- how many data nodes -->\n     * <property name=\"count\">3</property>\n     * </function>\n     * }\n     * <br>\n     * shard table datanode(2) < function count(3) 此时检测为不匹配\n     */\n    private void checkRuleSuitTable(TableConfig tableConf) {\n        AbstractPartitionAlgorithm function = tableConf.getRule().getRuleAlgorithm();\n        int suitValue = function.suitableFor(tableConf);\n        switch (suitValue) {\n            case -1:\n                // 少节点,给提示并抛异常\n                throw new ConfigException(\"Illegal table conf : table [ \" + tableConf.getName() + \" ] rule function [ \"\n                        + tableConf.getRule().getFunctionName() + \" ] partition size : \" + tableConf.getRule().getRuleAlgorithm().getPartitionNum() + \" > table datanode size : \"\n                        + tableConf.getDataNodes().size() + \", please make sure table datanode size = function partition size\");\n            case 0:\n                // table datanode size == rule function partition size\n                break;\n            case 1:\n                // 有些节点是多余的,给出warn log\n                LOGGER.warn(\"table conf : table [ {} ] rule function [ {} ] partition size : {} < table datanode size : {} , this cause some datanode to be redundant\",\n                        new String[]{\n                                tableConf.getName(),\n                                tableConf.getRule().getFunctionName(),\n                                String.valueOf(tableConf.getRule().getRuleAlgorithm().getPartitionNum()),\n                                String.valueOf(tableConf.getDataNodes().size())\n                        });\n                break;\n        }\n    }\n","sourceCodeStart":575,"sourceCodeEnd":611,"githubUrl":"https://github.com/MyCATApache/Mycat-Server/blob/65f8d8beb752f935752f2a0eec0ab017facab9ef/src/main/java/io/mycat/config/loader/xml/XMLSchemaLoader.java#L575-L611","documentation":"Thrown by XMLSchemaLoader.checkRuleSuitTable when a sharded table's partition algorithm declares more partitions (getPartitionNum) than the table has dataNodes (suitableFor returns -1). Mycat requires table datanode count >= function partition count so every partition maps to a real node.","triggerScenarios":"A table with e.g. rule=\"auto-sharding-long\" (partitionNum=10) but only 2 dataNode entries; commonly with mod/hash algorithms after reducing the dataNode list without adjusting the rule function config.","commonSituations":"Scaling down dataNodes in schema.xml while rule.xml function (count/length arrays) still assumes the old node count; copying a rule from a larger deployment; partition-count mismatch after range expansion changes.","solutions":["Update the rule function in rule.xml (e.g. partitionCount/partitionLength) so its partition count equals the table's dataNode count","Add more dataNode entries to the table so its count matches the function's partitionNum","Switch the table to a rule function whose partition count matches the current dataNode size"],"exampleFix":"// before (rule.xml)\n<function name=\"func1\" class=\"Hash\"><property name=\"partitionCount\">10</property></function>\n<!-- table has only 2 dataNodes -->\n// after\n<function name=\"func1\" class=\"Hash\"><property name=\"partitionCount\">2</property></function>","handlingStrategy":"validation","validationCode":"// check partition count vs datanode count before load\nint partitionNum = ruleFunction.getPartitionNum();\nList<String> dataNodes = Arrays.asList(table.getAttribute(\"dataNode\").split(\",\"));\nif (partitionNum > dataNodes.size())\n    throw new IllegalStateException(\"partition size \" + partitionNum + \" > datanode size \" + dataNodes.size());","typeGuard":null,"tryCatchPattern":"try {\n    configLoader.load();\n} catch (ConfigException e) {\n    if (e.getMessage().contains(\"partition size\") && e.getMessage().contains(\"datanode size\")) {\n        log.error(\"Align rule.xml function partitionCount with the table's dataNode count\", e);\n    }\n    throw e;\n}","preventionTips":["Whenever you change a table's dataNode list, recompute the rule function's partition count","Keep partitionCount in rule.xml equal to the number of dataNodes per sharded table","Document the rule-to-datanode pairing for each sharded table in your config notes"],"tags":["config","sharding","partition-mismatch"],"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-16T04:17:20.429Z"}