Zouxxyy commented on code in PR #8941:
URL: https://github.com/apache/hudi/pull/8941#discussion_r1227954534


##########
hudi-common/src/main/java/org/apache/hudi/common/table/timeline/HoodieActiveTimeline.java:
##########
@@ -234,73 +234,63 @@ public HoodieInstant revertToInflight(HoodieInstant 
instant) {
 
   public void deleteInflight(HoodieInstant instant) {
     ValidationUtils.checkArgument(instant.isInflight());
-    deleteInstantFile(instant);
+    deleteInstant(instant);
   }
 
   public void deletePending(HoodieInstant instant) {
     ValidationUtils.checkArgument(!instant.isCompleted());
-    deleteInstantFile(instant);
+    deleteInstant(instant);
   }
 
   public void deleteCompletedRollback(HoodieInstant instant) {
     ValidationUtils.checkArgument(instant.isCompleted());
-    deleteInstantFile(instant);
-  }
-
-  public static void deleteInstantFile(FileSystem fs, String metaPath, 
HoodieInstant instant) {
-    try {
-      fs.delete(new Path(metaPath, instant.getFileName()), false);
-    } catch (IOException e) {
-      throw new HoodieIOException("Could not delete instant file" + 
instant.getFileName(), e);
-    }
+    deleteInstant(instant);
   }
 
   public void deleteEmptyInstantIfExists(HoodieInstant instant) {
     ValidationUtils.checkArgument(isEmpty(instant));
-    deleteInstantFileIfExists(instant);
+    deleteInstantIfExists(instant);
   }
 
   public void deleteCompactionRequested(HoodieInstant instant) {
     ValidationUtils.checkArgument(instant.isRequested());
     ValidationUtils.checkArgument(Objects.equals(instant.getAction(), 
HoodieTimeline.COMPACTION_ACTION));
-    deleteInstantFile(instant);
+    deleteInstant(instant);
   }
 
   /**
    * Note: This method should only be used in the case that delete 
requested/inflight instant or empty clean instant,
    * and completed commit instant in an archive operation.
    */
-  public void deleteInstantFileIfExists(HoodieInstant instant) {
-    LOG.info("Deleting instant " + instant);
-    Path commitFilePath = getInstantFileNamePath(instant.getFileName());
-    try {
-      if (metaClient.getFs().exists(commitFilePath)) {
-        boolean result = metaClient.getFs().delete(commitFilePath, false);
-        if (result) {
-          LOG.info("Removed instant " + instant);
-        } else {
-          throw new HoodieIOException("Could not delete instant " + instant);
-        }
-      } else {
-        LOG.warn("The commit " + commitFilePath + " to remove does not exist");
-      }
-    } catch (IOException e) {
-      throw new HoodieIOException("Could not remove commit " + commitFilePath, 
e);
+  public void deleteInstantIfExists(HoodieInstant instant) {
+    if (instantExists(instant)) {

Review Comment:
   change `deleteInstantFileIfExists`  to `deleteInstantIfExists`, because 
instant can't just be a file in FS, in RFC-36, it's a record in database.
   
   An instant object contains state, action, timestamp, which can uniquely 
determine a metadata file 



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