|
@@ -10,6 +10,7 @@ import java.util.List;
|
|
import java.util.concurrent.TimeUnit;
|
|
import java.util.concurrent.TimeUnit;
|
|
import java.util.concurrent.atomic.AtomicLong;
|
|
import java.util.concurrent.atomic.AtomicLong;
|
|
|
|
|
|
|
|
+import com.alibaba.otter.canal.parse.driver.mysql.packets.MysqlGTIDSet;
|
|
import org.apache.commons.lang.StringUtils;
|
|
import org.apache.commons.lang.StringUtils;
|
|
import org.apache.commons.lang.math.NumberUtils;
|
|
import org.apache.commons.lang.math.NumberUtils;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
@@ -118,7 +119,7 @@ public class MysqlConnection implements ErosaConnection {
|
|
/**
|
|
/**
|
|
* 加速主备切换时的查找速度,做一些特殊优化,比如只解析事务头或者尾
|
|
* 加速主备切换时的查找速度,做一些特殊优化,比如只解析事务头或者尾
|
|
*/
|
|
*/
|
|
- public void seek(String binlogfilename, Long binlogPosition, SinkFunction func) throws IOException {
|
|
|
|
|
|
+ public void seek(String binlogfilename, Long binlogPosition, String gtid, SinkFunction func) throws IOException {
|
|
updateSettings();
|
|
updateSettings();
|
|
loadBinlogChecksum();
|
|
loadBinlogChecksum();
|
|
sendBinlogDump(binlogfilename, binlogPosition);
|
|
sendBinlogDump(binlogfilename, binlogPosition);
|
|
@@ -130,6 +131,11 @@ public class MysqlConnection implements ErosaConnection {
|
|
decoder.handle(LogEvent.QUERY_EVENT);
|
|
decoder.handle(LogEvent.QUERY_EVENT);
|
|
decoder.handle(LogEvent.XID_EVENT);
|
|
decoder.handle(LogEvent.XID_EVENT);
|
|
LogContext context = new LogContext();
|
|
LogContext context = new LogContext();
|
|
|
|
+ // 若entry position存在gtid,则使用传入的gtid作为gtidSet 的拼接标准,否则同时开启gtid和tsdb时,会导致丢失初始化传入的gtid
|
|
|
|
+ if (StringUtils.isNotEmpty(gtid)) {
|
|
|
|
+ decoder.handle(LogEvent.GTID_LOG_EVENT);
|
|
|
|
+ context.setGtidSet(MysqlGTIDSet.parse(gtid));
|
|
|
|
+ }
|
|
context.setFormatDescription(new FormatDescriptionLogEvent(4, binlogChecksum));
|
|
context.setFormatDescription(new FormatDescriptionLogEvent(4, binlogChecksum));
|
|
while (fetcher.fetch()) {
|
|
while (fetcher.fetch()) {
|
|
accumulateReceivedBytes(fetcher.limit());
|
|
accumulateReceivedBytes(fetcher.limit());
|