zhoujinsong commented on code in PR #4209: URL: https://github.com/apache/amoro/pull/4209#discussion_r3233133950
########## amoro-ams/src/main/java/org/apache/amoro/server/process/iceberg/OrphanFilesCleaningProcess.java: ########## @@ -0,0 +1,79 @@ +/* + * 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 cleaning Iceberg orphan files. */ +public class OrphanFilesCleaningProcess extends TableProcess implements LocalProcess { + + private static final Logger LOG = LoggerFactory.getLogger(OrphanFilesCleaningProcess.class); + + public OrphanFilesCleaningProcess(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.cleanOrphanFiles(); + tableRuntime.updateState( Review Comment: The old `OrphanFilesCleaningExecutor` introduced a random startup jitter via `getExecutorDelay()`: ```java // OrphanFilesCleaningExecutor.java @Override protected long getExecutorDelay() { return ThreadLocalRandom.current().nextLong(interval.toMillis()); } ``` This was intentional — with many tables registered, a fixed `executorDelay` causes all tables to be evaluated (and potentially trigger cleanup) at nearly the same time, creating a thundering-herd on the underlying storage. In the new framework, `DefaultActionCoordinator.getExecutorDelay()` always returns the full interval: ```java @Override public long getExecutorDelay() { return strategy.getTriggerInterval().toMillis(); } ``` This is a framework-level behavior (shared with `SnapshotsExpiringProcess`), so fixing it here may be out of scope. But it is worth tracking — either by adding jitter support to `ProcessTriggerStrategy`, or by overriding `getExecutorDelay()` in `DefaultActionCoordinator` with a random offset bounded by the interval. -- 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]
