xushiyan commented on code in PR #8422:
URL: https://github.com/apache/hudi/pull/8422#discussion_r1164167633


##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/client/HoodieTimelineArchiver.java:
##########
@@ -475,7 +485,24 @@ private Stream<HoodieInstant> getCommitInstantsToArchive() 
throws IOException {
                       HoodieTimeline.compareTimestamps(s.getTimestamp(), 
LESSER_THAN, instantToRetain.getTimestamp()))
                   .orElse(true)
           );
-      return instantToArchiveStream.limit(commitTimeline.countInstants() - 
minInstantsToKeep);
+      List<HoodieInstant> instantsToArchive = 
instantToArchiveStream.limit(commitTimeline.countInstants() - 
minInstantsToKeep).collect(Collectors.toList());
+      // If cleaner is based on hours, lets ensure hudi does not archive 
commits yet to cleaned by the cleaner.
+      if (config.getCleanerPolicy() == 
HoodieCleaningPolicy.KEEP_LATEST_BY_HOURS && !instantsToArchive.isEmpty()) {
+        String latestCommitToArchive = 
instantsToArchive.get(instantsToArchive.size() - 1).getTimestamp();
+        try {
+          Instant latestCommitInstant = 
HoodieActiveTimeline.parseDateFromInstantTime(commitTimeline.lastInstant().get().getTimestamp()).toInstant();
+          ZonedDateTime currentDateTime = 
ZonedDateTime.ofInstant(latestCommitInstant, ZoneId.systemDefault());

Review Comment:
   we need to consider timezone setting for timeline 
`org.apache.hudi.common.table.HoodieTableConfig#TIMELINE_TIMEZONE`



##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/client/HoodieTimelineArchiver.java:
##########
@@ -475,7 +485,24 @@ private Stream<HoodieInstant> getCommitInstantsToArchive() 
throws IOException {
                       HoodieTimeline.compareTimestamps(s.getTimestamp(), 
LESSER_THAN, instantToRetain.getTimestamp()))
                   .orElse(true)
           );
-      return instantToArchiveStream.limit(commitTimeline.countInstants() - 
minInstantsToKeep);
+      List<HoodieInstant> instantsToArchive = 
instantToArchiveStream.limit(commitTimeline.countInstants() - 
minInstantsToKeep).collect(Collectors.toList());
+      // If cleaner is based on hours, lets ensure hudi does not archive 
commits yet to cleaned by the cleaner.
+      if (config.getCleanerPolicy() == 
HoodieCleaningPolicy.KEEP_LATEST_BY_HOURS && !instantsToArchive.isEmpty()) {

Review Comment:
   this is another special rule added to the codebase and increased logic 
complexity. how can we design it better so that cleaner policy can fit nicely 
with archiver. for e.g., cleaner policy can have an API say `canArchive()` and 
archiver just use it. we need to design better APIs rather than adding 
conditions to just make things work.



-- 
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]

Reply via email to