Skip to content

Commit

Permalink
[HUDI-3870] Add timeout rollback for flink online compaction (apache#…
Browse files Browse the repository at this point in the history
  • Loading branch information
danny0405 authored Apr 13, 2022
1 parent 0281725 commit 6f9b02d
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,7 @@ public void notifyCheckpointComplete(long checkpointId) {
// 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
Expand All @@ -99,14 +98,22 @@ public void notifyCheckpointComplete(long checkpointId) {

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.
LOG.info("No compaction plan for checkpoint " + checkpointId);
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
Expand Down

0 comments on commit 6f9b02d

Please sign in to comment.