You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@polaris.apache.org by di...@apache.org on 2026/07/01 05:04:18 UTC

(polaris) branch main updated: perf: remove redundant exists check before deleteFile (saves cloud API calls) (#4928)

This is an automated email from the ASF dual-hosted git repository.

dimas-b pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/polaris.git


The following commit(s) were added to refs/heads/main by this push:
     new 99417dcc08 perf: remove redundant exists check before deleteFile (saves cloud API calls) (#4928)
99417dcc08 is described below

commit 99417dcc08af26f53253cbd7bb963b649a111a61
Author: vignesh_A <16...@users.noreply.github.com>
AuthorDate: Wed Jul 1 10:34:14 2026 +0530

    perf: remove redundant exists check before deleteFile (saves cloud API calls) (#4928)
    
    - Direct deleteFile (idempotent).
    - Narrow NotFoundException catch only for InMemoryFileIO/test compatibility.
    - Added debug log in the NotFound case as suggested in review.
---
 .../polaris/service/task/FileCleanupTaskHandler.java   | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/runtime/service/src/main/java/org/apache/polaris/service/task/FileCleanupTaskHandler.java b/runtime/service/src/main/java/org/apache/polaris/service/task/FileCleanupTaskHandler.java
index b149508ed8..c62eca6471 100644
--- a/runtime/service/src/main/java/org/apache/polaris/service/task/FileCleanupTaskHandler.java
+++ b/runtime/service/src/main/java/org/apache/polaris/service/task/FileCleanupTaskHandler.java
@@ -23,6 +23,7 @@ import java.util.concurrent.ExecutorService;
 import java.util.concurrent.TimeUnit;
 import org.apache.iceberg.CatalogUtil;
 import org.apache.iceberg.catalog.TableIdentifier;
+import org.apache.iceberg.exceptions.NotFoundException;
 import org.apache.iceberg.io.FileIO;
 import org.apache.polaris.core.context.CallContext;
 import org.apache.polaris.core.entity.TaskEntity;
@@ -90,16 +91,17 @@ public abstract class FileCleanupTaskHandler implements TaskHandler {
     }
     return CompletableFuture.runAsync(
             () -> {
-              // totally normal for a file to already be missing, e.g. a data file
-              // may be in multiple manifests. There's a possibility we check the
-              // file's existence, but then it is deleted before we have a chance to
-              // send the delete request. In such a case, we <i>should</i> retry
-              // and find
-              if (TaskUtils.exists(file, fileIO)) {
+              // deleteFile is idempotent on cloud object stores (S3 DeleteObject, etc.).
+              // It is totally normal for a data file to already be missing (e.g. present
+              // in multiple manifests across snapshots). We call delete directly.
+              // Some FileIO impls (e.g. InMemory) throw NotFound on missing; we treat that
+              // as success (already deleted).
+              try {
                 fileIO.deleteFile(file);
-              } else {
+              } catch (NotFoundException nfe) {
+                // already gone (e.g. InMemoryFileIO or race)
                 LOGGER
-                    .atInfo()
+                    .atDebug()
                     .addKeyValue("file", file)
                     .addKeyValue("baseFile", baseFile != null ? baseFile : "")
                     .addKeyValue("tableId", tableId)