Closed zbingwen closed 4 months ago
restoredIntervalEnd logic is wrong
public static GtidSet fixRestoredGtidSetOld(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());
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(
new com.github.shyiko.mysql.binlog.GtidSet.Interval(
serverInterval.getStart(), restoredIntervalEnd));
}
}
newSet.put(
uuidSet.getUUID(),
new GtidSet.UUIDSet(
new com.github.shyiko.mysql.binlog.GtidSet.UUIDSet(
uuidSet.getUUID(), newIntervals)));
} else {
newSet.put(uuidSet.getUUID(), uuidSet);
}
}
return new GtidSet(newSet);
}
change to below , test is correct.
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());
if (serverUuidSet != null) {
List<GtidSet.Interval> restoredIntervals = uuidSet.getIntervals();
int restoredIntervalsSize = restoredIntervals.size();
List<GtidSet.Interval> serverIntervals = serverUuidSet.getIntervals();
List<com.github.shyiko.mysql.binlog.GtidSet.Interval> newIntervals =
new ArrayList<>();
for (int i = 0; i < serverIntervals.size(); i++) {
GtidSet.Interval serverInterval = serverIntervals.get(i);
if (i < restoredIntervalsSize) {
GtidSet.Interval restoredInterval = restoredIntervals.get(i);
if (serverInterval.getEnd() <= restoredInterval.getEnd()) {
newIntervals.add(
new com.github.shyiko.mysql.binlog.GtidSet.Interval(
serverInterval.getStart(), serverInterval.getEnd()));
} else if (serverInterval.getStart() <= restoredInterval.getEnd()
&& serverInterval.getEnd() > restoredInterval.getEnd()) {
newIntervals.add(
new com.github.shyiko.mysql.binlog.GtidSet.Interval(
serverInterval.getStart(), restoredInterval.getEnd()));
}
} else {
newIntervals.add(
new com.github.shyiko.mysql.binlog.GtidSet.Interval(
serverInterval.getStart(), serverInterval.getEnd()));
}
}
newSet.put(
uuidSet.getUUID(),
new GtidSet.UUIDSet(
new com.github.shyiko.mysql.binlog.GtidSet.UUIDSet(
uuidSet.getUUID(), newIntervals)));
} else {
newSet.put(uuidSet.getUUID(), uuidSet);
}
}
return new GtidSet(newSet);
}
As required by Apache Flink, please report bugs or new features on Apache Jira under the project Flink using component tag Flink CDC. You must have a JIRA account in order to log cases and issues. If you don’t have an ASF JIRA account, you can request one at the ASF Self-serve portal, account creation requires review by the PMC member of the application project, which normally takes one to two working days to be approved.
你好,缺陷和新功能需要在 Apache Jira 或 Flink 邮件列表(dev@flink.apache.org)中反馈,而不是在这里创建新 issue。 GitHub 上的新 issue 会被忽略且自动关闭。
version : flinkcdc 3.0
Merged GTID set is aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa:1-219984950:220530100-221264502 is Incorrect
log: