本文主要是介绍maxwell元数据问题,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
1.问题
"Couldn't find table xxx in xxxx 相关的schema问题
2.分析
2.1 代码本身存在缺陷
saveSchema缺少savePosition
2.2 DBA相关的操作
rename table `test`.`user` to `test`.user_bak;
rename table dev.user to `test`.`user`;
在此场景下缺少schema的处理
解决方案
BinlogConnectorReplicator下针对捕获InvalidSchemaError处理
public Schema lossSchema(String lossDb,String lossTab) throws SQLException, SchemaStoreException {Schema oldSchema = null;try(Connection connection = schemaConnectionPool.getConnection()) {SchemaCapturer capturer = new SchemaCapturer(connection, caseSensitivity);Database single = capturer.loss(lossDb,lossTab);oldSchema = getSchema();Database old = oldSchema.findDatabase(lossDb);if(old==null){oldSchema.getDatabases().add(single);return oldSchema;}oldSchema.getDatabases().stream().filter(item -> item.getName().equalsIgnoreCase(lossDb)).forEach(d->{Table singleTable = single.getTableList().get(0);if(d.hasTable(singleTable.getName())){d.getTableList().forEach(t->{if(t.getName().equalsIgnoreCase(singleTable.getName())){t=singleTable;}});}else{d.addTable(singleTable);}});}if(oldSchema!=null){savedSchema.setSchema(oldSchema);savedSchema.saveForce(,true);}return oldSchema;}
这篇关于maxwell元数据问题的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!