kbuci commented on code in PR #18302:
URL: https://github.com/apache/hudi/pull/18302#discussion_r2963307924


##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/client/BaseHoodieTableServiceClient.java:
##########
@@ -1155,13 +1178,37 @@ private List<String> 
getInstantsToRollbackForLazyCleanPolicy(HoodieTableMetaClie
     if (!expiredInstants.isEmpty()) {
       // Only return instants that haven't been completed by other writers
       metaClient.reloadActiveTimeline();
-      HoodieTimeline refreshedInflightTimeline = 
getInflightTimelineExcludeCompactionAndClustering(metaClient);
-      return 
expiredInstants.stream().filter(refreshedInflightTimeline::containsInstant).collect(Collectors.toList());
+      HoodieTimeline refreshedIncompleteTimeline = 
metaClient.getActiveTimeline().filterInflightsAndRequested();
+      return expiredInstants.stream().filter(instantTime ->
+          refreshedIncompleteTimeline.containsInstant(instantTime)
+      ).collect(Collectors.toList());
     } else {
       return Collections.emptyList();
     }
   }
 
+  public boolean isClusteringInstantEligibleForRollback(HoodieTableMetaClient 
metaClient, HoodieInstant instant) {
+    return config.isExpirationOfClusteringEnabled()
+        && hasInstantExpired(metaClient, instant.requestedTime(), 
config.getClusteringExpirationTimeMins())
+        && ClusteringUtils.isClusteringInstant(
+            metaClient.getActiveTimeline(), instant, 
metaClient.getInstantGenerator());
+  }
+
+  private static boolean hasInstantExpired(HoodieTableMetaClient metaClient, 
String instantTime, long expirationMins) {
+    try {
+      ZoneId zoneId = 
metaClient.getTableConfig().getTimelineTimezone().getZoneId();
+      LocalDateTime instantDateTime = LocalDateTime.parse(
+          HoodieInstantTimeGenerator.fixInstantTimeCompatibility(instantTime),
+          HoodieInstantTimeGenerator.MILLIS_INSTANT_TIME_FORMATTER);
+      long instantEpochMs = 
instantDateTime.atZone(zoneId).toInstant().toEpochMilli();
+      long ageMs = System.currentTimeMillis() - instantEpochMs;

Review Comment:
   Updated



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