apache/iceberg · warning

Failed to bulk delete {} files

Error message

Failed to bulk delete {} files

What it means

A WARN log when the generic bulk deletion path throws a RuntimeException other than BulkDeletionFailureException — i.e. the bulk delete operation failed wholesale rather than partially. No retry is performed; the files are left in storage and the surrounding operation (table drop) continues, so this indicates leftover/orphan files. Note this message has only the file-type placeholder, not the file path.

Source

Thrown at core/src/main/java/org/apache/iceberg/CatalogUtil.java:230

  }

  /**
   * Helper to delete files. Bulk deletion is used if possible.
   *
   * @param io FileIO for deletes
   * @param files files to delete
   * @param type type of files being deleted
   * @param concurrent controls concurrent deletion. Only applicable for non-bulk FileIO
   */
  public static void deleteFiles(
      FileIO io, Iterable<String> files, String type, boolean concurrent) {
    if (io instanceof SupportsBulkOperations bulkIO) {
      try {
        bulkIO.deleteFiles(files);
      } catch (BulkDeletionFailureException e) {
        LOG.warn("Failed to bulk delete {} {} files", e.numberFailedObjects(), type, e);
      } catch (RuntimeException e) {
        LOG.warn("Failed to bulk delete {} files", type, e);
      }
    } else {
      if (concurrent) {
        concurrentlyDeleteFiles(io, files, type);
      } else {
        files.forEach(file -> deleteFile(io, file, type));
      }
    }
  }

  private static void concurrentlyDeleteFiles(FileIO io, Iterable<String> files, String type) {
    Tasks.foreach(files)
        .executeWith(ThreadPools.getWorkerPool())
        .noRetry()
        .suppressFailureWhenFinished()
        .onFailure((file, exc) -> LOG.warn("Failed to delete {} file: {}", type, file, exc))
        .run(io::deleteFile);
  }

View on GitHub (pinned to 86d9c8fc54)

Solutions

  1. Inspect the chained exception in the log to identify the underlying SDK/IO failure and fix credentials/region/endpoint config.
  2. Re-run cleanup afterwards (orphan file removal) to delete the leaked files.
  3. If using a custom FileIO, verify its deleteFiles implementation actually deletes all supplied paths.
  4. Fall back by configuring a non-bulk FileIO path (concurrent=false) if the bulk implementation is unreliable.

Example fix

// before
catalog.dropTable(identifier); // bulk delete blew up, files remain
// after: sweep leftovers with explicit IO
catalog.dropTable(identifier);
SparkActions.get().deleteOrphanFiles(spark, tableLocation).execute();
Defensive patterns

Strategy: fallback

Try / catch

try { catalog.dropTable(id); } finally { runOrphanCleanup(tableLocation); }

Prevention

When it happens

Trigger: SupportsBulkOperations.deleteFiles throws unexpected runtime exceptions: SDK client misconfiguration, missing credentials, network failures, or an UnsupportedOperationException from a misconfigured bulk-capable FileIO.

Common situations: Expired cloud credentials mid-job; wrong region/endpoint configuration in S3FileIO; custom FileIO implementations whose deleteFiles is buggy or unimplemented.

Understand the failure class

Background: "failed to write file", "Could not save figure", "Error saving remote file" — file write failed: causes and fixes across languages and libraries — this error's family across 38 libraries.

Related errors


AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12). Data as JSON: /api/errors/2f9f15b054ece7e7. Report an issue: GitHub.