danny0405 commented on code in PR #9039:
URL: https://github.com/apache/hudi/pull/9039#discussion_r1241015763
##########
hudi-common/src/main/java/org/apache/hudi/common/util/CompactionUtils.java:
##########
@@ -345,22 +345,34 @@ public static Option<Pair<HoodieTimeline, HoodieInstant>>
getDeltaCommitsSinceLa
* @return the oldest instant to keep for MOR compaction.
*/
public static Option<HoodieInstant> getOldestInstantToRetainForCompaction(
- HoodieActiveTimeline activeTimeline, int maxDeltaCommits) {
+ HoodieActiveTimeline activeTimeline, HoodieTableMetaClient metaClient,
int maxDeltaCommits) throws IOException {
+ Option<HoodieInstant> oldestDeltaCommitToRetain = Option.empty();
Option<Pair<HoodieTimeline, HoodieInstant>> deltaCommitsInfoOption =
CompactionUtils.getDeltaCommitsSinceLatestCompaction(activeTimeline);
if (deltaCommitsInfoOption.isPresent()) {
Pair<HoodieTimeline, HoodieInstant> deltaCommitsInfo =
deltaCommitsInfoOption.get();
HoodieTimeline deltaCommitTimeline = deltaCommitsInfo.getLeft();
int numDeltaCommits = deltaCommitTimeline.countInstants();
if (numDeltaCommits < maxDeltaCommits) {
- return Option.of(deltaCommitsInfo.getRight());
+ oldestDeltaCommitToRetain = Option.of(deltaCommitsInfo.getRight());
} else {
// delta commits with the last one to keep
List<HoodieInstant> instants =
deltaCommitTimeline.getInstantsAsStream()
.limit(numDeltaCommits - maxDeltaCommits +
1).collect(Collectors.toList());
- return Option.of(instants.get(instants.size() - 1));
+ oldestDeltaCommitToRetain = Option.of(instants.get(instants.size() -
1));
}
}
- return Option.empty();
+
+ HoodieTimeline completedCompactionTimeLine =
activeTimeline.getCommitTimeline()
+ .filterCompletedInstants();
+ Option<HoodieInstant> oldestInstantToRetain =
CleanerUtils.getOldestInstantToRetainFromTimeline(activeTimeline, metaClient,
completedCompactionTimeLine);
+
+ Option<HoodieInstant> finalOldestDeltaCommitToRetain =
oldestDeltaCommitToRetain;
+ if (oldestDeltaCommitToRetain.isPresent()
+ && oldestInstantToRetain.map(instant ->
instant.compareTo(finalOldestDeltaCommitToRetain.get()) > 0).orElse(true)) {
+ oldestInstantToRetain = oldestDeltaCommitToRetain;
+ }
+
+ return oldestInstantToRetain;
Review Comment:
Not sure which code snippet guards the correctness, for clustering with
incremental cleaning, the `instant to retain` is specifically fixed by fetching
the instant from the `CleanPlan`, what's the nuances for compaction?
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]