zhoujinsong commented on code in PR #4214:
URL: https://github.com/apache/amoro/pull/4214#discussion_r3257563979


##########
amoro-ams/src/main/java/org/apache/amoro/server/process/iceberg/DanglingDeleteFilesCleaningProcess.java:
##########
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.amoro.server.process.iceberg;
+
+import org.apache.amoro.Action;
+import org.apache.amoro.AmoroTable;
+import org.apache.amoro.IcebergActions;
+import org.apache.amoro.TableRuntime;
+import org.apache.amoro.maintainer.TableMaintainer;
+import org.apache.amoro.process.ExecuteEngine;
+import org.apache.amoro.process.LocalProcess;
+import org.apache.amoro.process.TableProcess;
+import org.apache.amoro.server.optimizing.maintainer.TableMaintainerFactory;
+import org.apache.amoro.server.table.DefaultTableRuntime;
+import org.apache.amoro.shade.guava32.com.google.common.collect.Maps;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Map;
+
+/** Local table process for expiring Iceberg dangling delete files. */
+public class DanglingDeleteFilesCleaningProcess extends TableProcess 
implements LocalProcess {
+
+  private static final Logger LOG =
+      LoggerFactory.getLogger(DanglingDeleteFilesCleaningProcess.class);
+
+  public DanglingDeleteFilesCleaningProcess(TableRuntime tableRuntime, 
ExecuteEngine engine) {
+    super(tableRuntime, engine);
+  }
+
+  @Override
+  public String tag() {
+    return getAction().getName().toLowerCase();
+  }
+
+  @Override
+  public void run() {
+    try {
+      AmoroTable<?> amoroTable = tableRuntime.loadTable();
+      TableMaintainer tableMaintainer = 
TableMaintainerFactory.create(amoroTable, tableRuntime);
+      tableMaintainer.cleanDanglingDeleteFiles();
+      tableRuntime.updateState(
+          DefaultTableRuntime.CLEANUP_STATE_KEY,
+          cleanUp -> 
cleanUp.setLastDanglingDeleteFilesCleanTime(System.currentTimeMillis()));
+    } catch (Throwable t) {

Review Comment:
   `LocalExecutionEngine` tracks process status via 
`CompletableFuture.whenComplete`: if `run()` throws, the process is marked 
`FAILED`; if it returns normally, it is marked `SUCCESS`.
   
   By catching `Throwable` and swallowing it here, exceptions never propagate 
to the `CompletableFuture`, so the process status is **always reported as 
`SUCCESS`** even when the actual operation failed. This makes failure invisible 
to the framework and to operators.
   
   The fix is to let exceptions propagate out of `run()`. The same issue exists 
in `OrphanFilesCleaningProcess` and should be fixed there as well.
   
   ```java
   @Override
   public void run() {
     AmoroTable<?> amoroTable = tableRuntime.loadTable();
     TableMaintainer tableMaintainer = 
TableMaintainerFactory.create(amoroTable, tableRuntime);
     tableMaintainer.cleanDanglingDeleteFiles();
     tableRuntime.updateState(
         DefaultTableRuntime.CLEANUP_STATE_KEY,
         cleanUp -> 
cleanUp.setLastDanglingDeleteFilesCleanTime(System.currentTimeMillis()));
   }
   ```
   
   If a caught-and-logged pattern is intentional (e.g., to avoid flooding 
failure metrics for transient errors), consider wrapping in a 
`RuntimeException` so the framework still sees a failure:
   
   ```java
   } catch (Throwable t) {
     LOG.error("Unexpected dangling delete files cleaning error for table {}",
         tableRuntime.getTableIdentifier(), t);
     throw new RuntimeException(t);
   }
   ```
   



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