{"record":{"id":"6c0b49bdc17411a5","repo":"MyCATApache/Mycat-Server","slug":"new-old-table-config-is-not-equal","errorCode":null,"errorMessage":"new & old table config is not equal!","messagePattern":"new & old table config is not equal!","errorType":"exception","errorClass":"ConfigException","httpStatus":null,"severity":"error","filePath":"src/main/java/io/mycat/util/dataMigrator/ConfigComparer.java","lineNumber":153,"sourceCode":"\t\tif(!DataMigratorUtil.isKeyExistIgnoreCase(newSchemas,schemaName)){\n\t\t\tthrow new ConfigException(\"newSchema:\"+schemaName+\" is not exists!\");\n\t\t}\n\t\tMap<String, TableConfig> oldTables =  DataMigratorUtil.getValueIgnoreCase(oldSchemas, schemaName).getTables();\n\t\tMap<String, TableConfig> newTables = DataMigratorUtil.getValueIgnoreCase(newSchemas, schemaName).getTables();\n\t\tif(tables.length>0){\n\t\t\t//指定schema下的表进行迁移\n\t\t\tfor(int i =0;i<tables.length;i++){\n\t\t\t\tTableConfig oldTable =  DataMigratorUtil.getValueIgnoreCase(oldTables,tables[i]);\n\t\t\t\tTableConfig newTable = DataMigratorUtil.getValueIgnoreCase(newTables,tables[i]);\n\t\t\t\tloadMigratorTable(oldTable, newTable,schemaName,tables[i]);\n\t\t\t}\n\t\t}else{\n\t\t\t//迁移schema下所有的表\n\t\t\t//校验新旧schema中的table配置是否一致\n\t\t\tSet<String> oldSet = oldTables.keySet();\n\t\t\tSet<String> newSet = newTables.keySet();\n\t\t\tif(!oldSet.equals(newSet)){\n\t\t\t\tthrow new ConfigException(\"new & old table config is not equal!\");\n\t\t\t}\n\t\t\tfor(String tableName:oldSet){\n\t\t\t\tTableConfig oldTable = oldTables.get(tableName);\n\t\t\t\tTableConfig newTable = newTables.get(tableName);\n\t\t\t\tloadMigratorTable(oldTable, newTable,schemaName,tableName);\n\t\t\t}\n\t\t}\n\t\t\n\t}\n\t\n\t\n\t\n\tprivate void loadMigratorTable(TableConfig oldTable,TableConfig newTable,String schemaName,String tableName){\n\t\t//禁止配置非拆分表\n\t\tif(oldTable == null || newTable == null){\n\t\t\tthrow new ConfigException(\"please check tableFile.properties,make sure \"+schemaName+\":\"+tableName+\" is sharding table \");\n\t\t}\n\t\t//忽略全局表","sourceCodeStart":135,"sourceCodeEnd":171,"githubUrl":"https://github.com/MyCATApache/Mycat-Server/blob/65f8d8beb752f935752f2a0eec0ab017facab9ef/src/main/java/io/mycat/util/dataMigrator/ConfigComparer.java#L135-L171","documentation":"When migrating all tables under a schema (no explicit table list), ConfigComparer requires the set of table names to be identical in the old and new configurations. If the key sets differ, a ConfigException is thrown because safe migration cannot map tables that exist in only one config.","triggerScenarios":"Migrating a whole schema (tables entry empty) where the old schema.xml defines tables that the new schema.xml does not, or vice versa — e.g. a table was added or removed between configurations.","commonSituations":"Adding a new sharding table to the new config but not the old; removing a table in the new config; copy of schema.xml not kept in sync; typo in a table name in either config.","solutions":["Diff the <table> entries of the schema between old and new schema.xml and make the table sets identical.","If a table should not be migrated, list only the intended tables explicitly in tablesFile.properties instead of migrating all.","Fix misspelled table names so both configs match.","Remove leftover table definitions from whichever config should not have them."],"exampleFix":"// before: new config missing table\nold: order_main, order_detail ; new: order_main\n// after\nnew schema.xml also defines <table name=\"order_detail\" ...>","handlingStrategy":"validation","validationCode":"Set<String> oldT = oldSchema.getTables().keySet();\nSet<String> newT = newSchema.getTables().keySet();\nif (!oldT.equals(newT)) {\n    Set<String> diff = new HashSet<>(oldT); diff.removeAll(newT);\n    Set<String> diff2 = new HashSet<>(newT); diff2.removeAll(oldT);\n    throw new IllegalStateException(\"table set mismatch; only-old=\" + diff + \" only-new=\" + diff2);\n}","typeGuard":null,"tryCatchPattern":"try {\n    comparer.compare();\n} catch (ConfigException e) {\n    if (e.getMessage().contains(\"new & old table config is not equal\")) {\n        // diff <table> entries for the schema, align them, or list tables explicitly\n    }\n    throw e;\n}","preventionTips":["Align table sets in old/new schema.xml before migration planning","When tables differ intentionally, migrate them by explicit table list instead of whole-schema","Diff schema.xml files in CI before approving a migration plan"],"tags":["java","configuration","data-migration","sharding"],"backgroundTag":"schema-validation-failed","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"}