MyCATApache/Mycat-Server · error · ConfigException

table rule coulmns has multi values

Error message

table rule coulmns has multi values:${columnsEle.getTextContent()}

What it means

loadRule reads the <columns> element of a tableRule and splits its text on commas. MyCat's rule loading (this version) supports only one sharding column per rule, so a comma-separated column list throws this ConfigException. Note the typo 'coulmns' is in the original message.

Solutions

  1. Specify a single column in <columns> and restart.
  2. For composite sharding, write a custom AbstractPartitionAlgorithm that takes the row and computes from multiple fields, or precompute a combined sharding column upstream.
  3. Define separate tableRules only if the schema genuinely needs distinct single-column rules.

Example fix

// before (rule.xml)
<rule>
  <columns>cust_id,order_date</columns>
  <algorithm>hash-int</algorithm>
</rule>
// after
<rule>
  <columns>cust_id</columns>
  <algorithm>hash-int</algorithm>
</rule>
Defensive patterns

Strategy: validation

Validate before calling

// Ensure every rule's <columns> holds a single value
NodeList cols = doc.getElementsByTagName("columns");
for (int i = 0; i < cols.getLength(); i++) {
    String v = cols.item(i).getTextContent().trim();
    if (v.contains(",")) throw new IllegalStateException("multi-column rule unsupported: " + v);
}

Try / catch

try {
    ruleLoader.load();
} catch (ConfigException e) {
    if (e.getMessage().contains("coulmns has multi values")) {
        LOG.error("Single sharding column only: {}", e.getMessage());
    }
    throw e;
}

Prevention

When it happens

Trigger: A rule.xml <rule> block with <columns>col1,col2</columns>; loadRule -> SplitUtil.split yields length > 1 and throws.

Common situations: Trying to shard on multiple columns by listing them comma-separated; copied config from projects supporting composite columns; accidental trailing/inappropriate comma lists.

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

Appendix: source

Thrown at src/main/java/io/mycat/config/loader/xml/XMLRuleLoader.java:166

				AbstractPartitionAlgorithm func = functions.get(funName);
				if (func == null) {
					throw new ConfigException("can't find function of name :"
							+ funName);
				}
				rule.setRuleAlgorithm(func);
				//保存到tableRules
				tableRules.put(name, new TableRuleConfig(name, rule));
			}
		}
	}

	private RuleConfig loadRule(Element element) throws SQLSyntaxErrorException {
		//读取columns
		Element columnsEle = ConfigUtil.loadElement(element, "columns");
		String column = columnsEle.getTextContent();
		String[] columns = SplitUtil.split(column, ',', true);
		if (columns.length > 1) {
			throw new ConfigException("table rule coulmns has multi values:"
					+ columnsEle.getTextContent());
		}
		//读取algorithm
		Element algorithmEle = ConfigUtil.loadElement(element, "algorithm");
		String algorithm = algorithmEle.getTextContent();
		return new RuleConfig(column.toUpperCase(), algorithm);
	}

	/**
	 * function标签结构:
	 * <function name="partbymonth" class="io.mycat.route.function.PartitionByMonth">
	 *     <property name="dateFormat">yyyy-MM-dd</property>
	 *     <property name="sBeginDate">2015-01-01</property>
	 * </function>
	 * @param root
	 * @throws ClassNotFoundException
	 * @throws InstantiationException
	 * @throws IllegalAccessException

View on GitHub (pinned to 65f8d8beb7)