1
0

[HUDI-3870] Add timeout rollback for flink online compaction (#5314)

This commit is contained in:
Danny Chan
2022-04-13 20:05:48 +08:00
committed by GitHub
parent 0281725c6b
commit 6f9b02decb

View File

@@ -88,8 +88,7 @@ public class CompactionPlanOperator extends AbstractStreamOperator<CompactionPla
// when the earliest inflight instant has timed out, assumes it has failed
// already and just rolls it back.
// comment out: do we really need the timeout rollback ?
// CompactionUtil.rollbackEarliestCompaction(table, conf);
CompactionUtil.rollbackEarliestCompaction(table, conf);
scheduleCompaction(table, checkpointId);
} catch (Throwable throwable) {
// make it fail-safe
@@ -99,7 +98,8 @@ public class CompactionPlanOperator extends AbstractStreamOperator<CompactionPla
private void scheduleCompaction(HoodieFlinkTable<?> table, long checkpointId) throws IOException {
// the first instant takes the highest priority.
Option<HoodieInstant> firstRequested = table.getActiveTimeline().filterPendingCompactionTimeline()
HoodieTimeline pendingCompactionTimeline = table.getActiveTimeline().filterPendingCompactionTimeline();
Option<HoodieInstant> firstRequested = pendingCompactionTimeline
.filter(instant -> instant.getState() == HoodieInstant.State.REQUESTED).firstInstant();
if (!firstRequested.isPresent()) {
// do nothing.
@@ -107,6 +107,13 @@ public class CompactionPlanOperator extends AbstractStreamOperator<CompactionPla
return;
}
Option<HoodieInstant> firstInflight = pendingCompactionTimeline
.filter(instant -> instant.getState() == HoodieInstant.State.INFLIGHT).firstInstant();
if (firstInflight.isPresent()) {
LOG.warn("Waiting for pending compaction instant : " + firstInflight + " to complete, skip scheduling new compaction plans");
return;
}
String compactionInstantTime = firstRequested.get().getTimestamp();
// generate compaction plan