lvyanquan commented on code in PR #3845: URL: https://github.com/apache/flink-cdc/pull/3845#discussion_r2291165263
########## flink-cdc-connect/flink-cdc-source-connectors/flink-connector-mysql-cdc/src/main/java/io/debezium/connector/mysql/GtidUtils.java: ########## @@ -36,36 +38,64 @@ public class GtidUtils { public static GtidSet fixRestoredGtidSet(GtidSet serverGtidSet, GtidSet restoredGtidSet) { Map<String, GtidSet.UUIDSet> newSet = new HashMap<>(); serverGtidSet.getUUIDSets().forEach(uuidSet -> newSet.put(uuidSet.getUUID(), uuidSet)); - for (GtidSet.UUIDSet uuidSet : restoredGtidSet.getUUIDSets()) { - GtidSet.UUIDSet serverUuidSet = newSet.get(uuidSet.getUUID()); + for (GtidSet.UUIDSet restoredUuidSet : restoredGtidSet.getUUIDSets()) { + GtidSet.UUIDSet serverUuidSet = newSet.get(restoredUuidSet.getUUID()); if (serverUuidSet != null) { - long restoredIntervalEnd = getIntervalEnd(uuidSet); - List<com.github.shyiko.mysql.binlog.GtidSet.Interval> newIntervals = - new ArrayList<>(); - for (GtidSet.Interval serverInterval : serverUuidSet.getIntervals()) { - if (serverInterval.getEnd() <= restoredIntervalEnd) { - newIntervals.add( - new com.github.shyiko.mysql.binlog.GtidSet.Interval( - serverInterval.getStart(), serverInterval.getEnd())); - } else if (serverInterval.getStart() <= restoredIntervalEnd - && serverInterval.getEnd() > restoredIntervalEnd) { - newIntervals.add( + List<GtidSet.Interval> serverIntervals = serverUuidSet.getIntervals(); + List<GtidSet.Interval> restoredIntervals = restoredUuidSet.getIntervals(); + + long earliestRestoredTx = getMinIntervalStart(restoredIntervals); + + List<com.github.shyiko.mysql.binlog.GtidSet.Interval> merged = new ArrayList<>(); + + // Process each server interval + for (GtidSet.Interval serverInterval : serverIntervals) { + // First, check if any part comes before earliest restored + if (serverInterval.getStart() < earliestRestoredTx) { + long end = Math.min(serverInterval.getEnd(), earliestRestoredTx - 1); + merged.add( new com.github.shyiko.mysql.binlog.GtidSet.Interval( - serverInterval.getStart(), restoredIntervalEnd)); + serverInterval.getStart(), end)); Review Comment: Hi, @mielientiev. Can you help confirm my question? I am willing to push forward with this PR, but we need to consider all possible risks. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@flink.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org