zhoujinsong commented on code in PR #4214: URL: https://github.com/apache/amoro/pull/4214#discussion_r3257525966
########## 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: Catching `Throwable` silently swallows `InterruptedException`, which can prevent graceful shutdown. Consider re-interrupting the thread when an `InterruptedException` is caught: ```java } catch (InterruptedException e) { Thread.currentThread().interrupt(); LOG.warn( "Dangling delete files cleaning interrupted for table {}", tableRuntime.getTableIdentifier()); } catch (Throwable t) { LOG.error( "Unexpected dangling delete files cleaning error of table {}", tableRuntime.getTableIdentifier(), 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]
