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;
}
296

被折叠的 条评论
为什么被折叠?



