MyCATApache/Mycat-Server · error · ConfigException

: old & new partition column is not same!

Error message

{schemaName}:{tableName} old & new partition column is not same!

What it means

checkRuleConfig enforces that the sharding (partition) column stays the same between the old and new rule configurations. Data migration physically redistributes rows between data nodes; changing the partition column would make redistributed data inconsistent, so a ConfigException is thrown when the columns differ (case-insensitive compare).

Solutions

  1. Make the <columns> value identical in the old and new rule configurations for this table.
  2. If the sharding key genuinely must change, migrate data with another tool (e.g. dump/reload) instead of this data-migrator.
  3. Verify rule.xml referenced by both configs before rerunning.
  4. Check for case/whitespace differences in the column name.

Example fix

// before: new rule.xml
<columns>order_id</columns>
// after (match old config)
<columns>user_id</columns>
Defensive patterns

Strategy: validation

Validate before calling

RuleConfig oldRC = oldTable.getRule();
RuleConfig newRC = newTable.getRule();
if (oldRC == null || newRC == null ||
    !oldRC.getColumn().equalsIgnoreCase(newRC.getColumn())) {
    throw new IllegalArgumentException("partition column changed for " + tableName);
}

Try / catch

try {
    comparer.compare();
} catch (ConfigException e) {
    if (e.getMessage().contains("partition column is not same")) {
        // revert <columns> in new rule.xml to match old config
    }
    throw e;
}

Prevention

When it happens

Trigger: Running the migrator when the <rule><columns> value for a table differs between old and new rule.xml/schema.xml — e.g. changing sharding from user_id to order_id.

Common situations: Refactoring the sharding key during a migration; rule.xml edited for the new cluster pointing at a different column; copy-pasting rule config from another table.

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


AI-assisted analysis of MyCATApache/Mycat-Server@65f8d8beb7 (2026-09-11). Data as JSON: /api/errors/b5c79a67a56d684d. Report an issue: GitHub.

Appendix: source

Thrown at src/main/java/io/mycat/util/dataMigrator/ConfigComparer.java:242

			DBHostConfig[]  writeHosts = dh.getWriteHosts();
			DBHostConfig currentWriteHost;
			if(isAwaysUseMaster){
				currentWriteHost = writeHosts[0];
			}else{
			    //迁移数据发生在当前切换后的数据源
				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 {

View on GitHub (pinned to 65f8d8beb7)