Skip to content

Commit

Permalink
[HUDI-4145] Archives the metadata file in HoodieInstant.State sequence (
Browse files Browse the repository at this point in the history
  • Loading branch information
danny0405 authored and yihua committed Jun 3, 2022
1 parent efb97a2 commit 6219f6c
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
Expand Down Expand Up @@ -504,10 +503,16 @@ private Stream<HoodieInstant> getInstantsToArchive() {
List<HoodieInstant> instantsToStream = groupByTsAction.get(Pair.of(hoodieInstant.getTimestamp(),
HoodieInstant.getComparableAction(hoodieInstant.getAction())));
if (instantsToStream != null) {
return instantsToStream.stream();
// sorts the instants in natural order to make sure the metadata files be removed
// in HoodieInstant.State sequence: requested -> inflight -> completed,
// this is important because when a COMPLETED metadata file is removed first,
// other monitors on the timeline(such as the compaction or clustering services) would
// mistakenly recognize the pending file as a pending operation,
// then all kinds of weird bugs occur.
return instantsToStream.stream().sorted();
} else {
// if a concurrent writer archived the instant
return Collections.EMPTY_LIST.stream();
return Stream.empty();
}
});
}
Expand Down

0 comments on commit 6219f6c

Please sign in to comment.