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

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值