zhuanshenbsj1 commented on code in PR #9038:
URL: https://github.com/apache/hudi/pull/9038#discussion_r1252072216


##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/table/action/clean/CleanPlanActionExecutor.java:
##########
@@ -111,14 +111,15 @@ HoodieCleanerPlan requestClean(HoodieEngineContext 
context) {
         LOG.info("Nothing to clean here. It is already clean");
         return 
HoodieCleanerPlan.newBuilder().setPolicy(HoodieCleaningPolicy.KEEP_LATEST_COMMITS.name()).build();
       }
-      LOG.info("Total Partitions to clean : " + partitionsToClean.size() + ", 
with policy " + config.getCleanerPolicy());
+      LOG.info("Earliest commit to retain for clean : " + 
(earliestInstant.isPresent() ? earliestInstant.get().getTimestamp() : "null"));
+      LOG.info("Total partitions to clean : " + partitionsToClean.size() + ", 
with policy " + config.getCleanerPolicy());
       int cleanerParallelism = Math.min(partitionsToClean.size(), 
config.getCleanerParallelism());
       LOG.info("Using cleanerParallelism: " + cleanerParallelism);
 
       context.setJobStatus(this.getClass().getSimpleName(), "Generating list 
of file slices to be cleaned: " + config.getTableName());
 
       Map<String, Pair<Boolean, List<CleanFileInfo>>> 
cleanOpsWithPartitionMeta = context
-          .map(partitionsToClean, partitionPathToClean -> 
Pair.of(partitionPathToClean, planner.getDeletePaths(partitionPathToClean)), 
cleanerParallelism)
+          .map(partitionsToClean, partitionPathToClean -> 
Pair.of(partitionPathToClean, planner.getDeletePaths(partitionPathToClean, 
earliestInstant)), cleanerParallelism)

Review Comment:
   Before modifying the earliestCommitToRetain, it was calculated twice.
   
   
![image](https://github.com/apache/hudi/assets/34104400/38b9d3bb-53bd-46c6-af9f-ebc40fce1605)
   
    Due to non atomic operation,  it is possible that the partition level 
calculation and the outer function calculation results are inconsistent,  which 
can result in partition level cleaning exceeding the outer 
earliestCommitToRetain.
   
   This may causes incorrect reading results for snapshot read in 
activetimeline.



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