MyCATApache/Mycat-Server · error · ConfigException

Illegal table conf : table

Error message

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

What it means

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.

Solutions

  1. Update the rule function in rule.xml (e.g. partitionCount/partitionLength) so its partition count equals the table's dataNode count
  2. Add more dataNode entries to the table so its count matches the function's partitionNum
  3. Switch the table to a rule function whose partition count matches the current dataNode size

Example fix

// before (rule.xml)
<function name="func1" class="Hash"><property name="partitionCount">10</property></function>
<!-- table has only 2 dataNodes -->
// after
<function name="func1" class="Hash"><property name="partitionCount">2</property></function>
Defensive patterns

Strategy: validation

Validate before calling

// check partition count vs datanode count before load
int partitionNum = ruleFunction.getPartitionNum();
List<String> dataNodes = Arrays.asList(table.getAttribute("dataNode").split(","));
if (partitionNum > dataNodes.size())
    throw new IllegalStateException("partition size " + partitionNum + " > datanode size " + dataNodes.size());

Try / catch

try {
    configLoader.load();
} catch (ConfigException e) {
    if (e.getMessage().contains("partition size") && e.getMessage().contains("datanode size")) {
        log.error("Align rule.xml function partitionCount with the table's dataNode count", e);
    }
    throw e;
}

Prevention

When it happens

Trigger: 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.

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

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/3a101845ea903e08. Report an issue: GitHub.

Appendix: source

Thrown at src/main/java/io/mycat/config/loader/xml/XMLSchemaLoader.java:593

     * }
     * <br>
     * 分片算法如下:<br>
     * {@code
     * <function name="mod-long" class="io.mycat.route.function.PartitionByMod">
     * <!-- how many data nodes -->
     * <property name="count">3</property>
     * </function>
     * }
     * <br>
     * shard table datanode(2) < function count(3) 此时检测为不匹配
     */
    private void checkRuleSuitTable(TableConfig tableConf) {
        AbstractPartitionAlgorithm function = tableConf.getRule().getRuleAlgorithm();
        int suitValue = function.suitableFor(tableConf);
        switch (suitValue) {
            case -1:
                // 少节点,给提示并抛异常
                throw new ConfigException("Illegal table conf : table [ " + tableConf.getName() + " ] rule function [ "
                        + tableConf.getRule().getFunctionName() + " ] partition size : " + tableConf.getRule().getRuleAlgorithm().getPartitionNum() + " > table datanode size : "
                        + tableConf.getDataNodes().size() + ", please make sure table datanode size = function partition size");
            case 0:
                // table datanode size == rule function partition size
                break;
            case 1:
                // 有些节点是多余的,给出warn log
                LOGGER.warn("table conf : table [ {} ] rule function [ {} ] partition size : {} < table datanode size : {} , this cause some datanode to be redundant",
                        new String[]{
                                tableConf.getName(),
                                tableConf.getRule().getFunctionName(),
                                String.valueOf(tableConf.getRule().getRuleAlgorithm().getPartitionNum()),
                                String.valueOf(tableConf.getDataNodes().size())
                        });
                break;
        }
    }

View on GitHub (pinned to 65f8d8beb7)