j1wonpark commented on code in PR #4107:
URL: https://github.com/apache/amoro/pull/4107#discussion_r2936397012


##########
amoro-ams/src/main/java/org/apache/amoro/server/process/iceberg/SnapshotsExpiringProcess.java:
##########
@@ -0,0 +1,82 @@
+/*
+ * 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.TableMaintainers;
+import org.apache.amoro.server.table.DefaultTableRuntime;
+import org.apache.amoro.server.table.cleanup.CleanupOperation;
+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 snapshots. */
+public class SnapshotsExpiringProcess extends TableProcess implements 
LocalProcess {
+
+  private static final Logger LOG = 
LoggerFactory.getLogger(SnapshotsExpiringProcess.class);
+
+  public SnapshotsExpiringProcess(TableRuntime tableRuntime, ExecuteEngine 
engine) {
+    super(tableRuntime, engine);
+  }
+
+  @Override
+  public String tag() {
+    return getAction().getName().toLowerCase();
+  }
+
+  @Override
+  public void run() {
+    try {
+      AmoroTable<?> amoroTable = tableRuntime.loadTable();

Review Comment:
   Building on your observation — the async submission also introduces a 
state-loss issue in `LocalExecutionEngine.getStatus()`.
   
   `getStatus()` removes the `Future` from the map on terminal states 
(`isDone`/`isCancelled`), making it **non-idempotent**:
   
   ```
   Call 1: future.isDone() == true → remove → SUCCESS
   Call 2: future == null          → KILLED  (wrong!)
   ```
   
   `TableProcessExecutor` polls `getStatus()` in a loop (line 107), so if any 
retry or concurrent access queries the same identifier twice after completion, 
it gets `KILLED` instead of the real result.
   
   There's also a TOCTOU race between `containsKey` and `get` across 
`cancelingInstances`/`activeInstances` (lines 67-70), since the compound 
check-then-act isn't atomic even with `ConcurrentHashMap`.



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