什么是间隔轮询?我们是如何做的?
• 校验轮询字段类型,如果不是数值类型且source并行度大于1,报错不支持
• 创建三个数据分片,startlocation为null或者配置的值,mod分别为0,1,2
• 构造SQL:不同SQL的取余函数不同,各自插件实现
select id,name,age from table where (id > ? and ) mod(id, 3) = 0 order by id;
select id,name,age from table where (id > ? and ) mod(id, 3) = 1 order by id;
select id,name,age from table where (id > ? and ) mod(id, 3) = 2 order by id;
• 执行SQL,查询并更新lastRow
• 第一次result查询完后,若脚本中没有配置startlocation,则之前的查询SQL为:
select id,name,age from table where mod(id, 3) = 1 order by id;
将其更新为:
select id,name,age from table where id > ? and mod(id, 3) = 1 order by id;
• CP时获取lastRow中的id值,保存到state中
三、实时数据还原上的实现和原理