MyCATApache/Mycat-Server · error · ConfigException
: old & new rule Algorithm is not same!
Error message
{schemaName}:{tableName} old & new rule Algorithm is not same! What it means
checkRuleConfig requires the partitioning algorithm class to be identical (assignable) before and after migration. If the old rule's algorithm and the new rule's algorithm are different classes, redistribution semantics change and the migrator throws a ConfigException.
Solutions
- Set the new rule's algorithm class to the same class as the old one for this table.
- If the algorithm must change, redistribute data outside this tool or adjust the tool constraints deliberately.
- Check the function definitions in rule.xml so both configs' rules resolve to the same AbstractPartitionAlgorithm subclass.
- Rerun the comparison after aligning algorithm classes.
Example fix
// before: new rule.xml <function name="func1" class="io.mycat.route.function.PartitionByHash"> // after (same class as old) <function name="func1" class="io.mycat.route.function.PartitionByMod">
Defensive patterns
Strategy: validation
Validate before calling
Class<?> oldAlg = oldTable.getRule().getRuleAlgorithm().getClass();
Class<?> newAlg = newTable.getRule().getRuleAlgorithm().getClass();
if (!oldAlg.equals(newAlg)) {
throw new IllegalArgumentException("algorithm class changed for " + tableName
+ ": " + oldAlg.getName() + " -> " + newAlg.getName());
} Try / catch
try {
comparer.compare();
} catch (ConfigException e) {
if (e.getMessage().contains("rule Algorithm is not same")) {
// point the new rule's function at the same algorithm class as the old one
}
throw e;
} Prevention
- Keep the same algorithm class per table across migration configs
- Plan algorithm changes as a separate dump/reload migration, not via data migrator
- Add a config-diff checklist item for rule.xml function classes
When it happens
Trigger: Changing the <algorithm> (function) used by a table's rule between old and new configs — e.g. switching from PartitionByMod to PartitionByHash or from auto-partition to a long-based partitioner.
Common situations: Upgrading sharding strategy (mod -> range/hash); rule.xml's function name remapped to a different class in the new config; table rule referencing a newly added algorithm function.
Understand the failure class
Background: Conflicting config options: "cannot be used together" — configuration validation errors across open-source libraries — this error's family across 162 libraries.
Related errors
- new & old table config is not equal!
- please check tableFile.properties,make sure
- : old & new partition column is not same!
- tablesFile.properties read fail!
- oldSchema: is not exists!
AI-assisted analysis of MyCATApache/Mycat-Server@65f8d8beb7 (2026-09-11).
Data as JSON: /api/errors/5a02cd74370a5ae1.
Report an issue: GitHub.
Appendix: source
Thrown at src/main/java/io/mycat/util/dataMigrator/ConfigComparer.java:248
currentWriteHost = writeHosts[Integer.valueOf(dnIndexProps.getProperty(dh.getName()))];
}
DataNode dn = new DataNode(name,currentWriteHost.getIp(), currentWriteHost.getPort(), currentWriteHost.getUser(), currentWriteHost.getPassword(), db, dbType,i++);
dataNodes.add(dn);
}
return dataNodes;
}
//校验前后路由规则是否一致
private void checkRuleConfig(RuleConfig oldRC,RuleConfig newRC,String schemaName,String tableName){
if(!oldRC.getColumn().equalsIgnoreCase(newRC.getColumn())){
throw new ConfigException(schemaName+":"+tableName+" old & new partition column is not same!");
}
AbstractPartitionAlgorithm oldAlg = oldRC.getRuleAlgorithm();
AbstractPartitionAlgorithm newAlg = newRC.getRuleAlgorithm();
//判断路由算法前后是否一致
if(!oldAlg.getClass().isAssignableFrom(newAlg.getClass())){
throw new ConfigException(schemaName+":"+tableName+" old & new rule Algorithm is not same!");
}
}
private Properties loadDnIndexProps() {
Properties prop = new Properties();
InputStream is = null;
try {
is = ConfigComparer.class.getResourceAsStream(DN_INDEX_FILE);
prop.load(is);
} catch (Exception e) {
throw new ConfigException("please check file \"dnindex.properties\" "+e.getMessage());
} finally {
try {
if(is !=null){
is.close();
}
} catch (IOException e) {
throw new ConfigException(e.getMessage());View on GitHub (pinned to 65f8d8beb7)