apache/iceberg · warning

Deleted only {} of {} file(s) ({})

Error message

Deleted only {} of {} file(s) ({})

What it means

A WARN log emitted by SparkCleanupUtil.delete after the Tasks.foreach loop completes when fewer files were deleted than requested (some deletions failed or files were already gone). It indicates partially successful cleanup of written/orphan data files.

Source

Thrown at spark/v4.1/spark/src/main/java/org/apache/iceberg/spark/source/SparkCleanupUtil.java:115

    Tasks.foreach(paths)
        .executeWith(ThreadPools.getWorkerPool())
        .stopRetryOn(NotFoundException.class)
        .suppressFailureWhenFinished()
        .onFailure((path, exc) -> LOG.warn("Failed to delete {} ({})", path, context, exc))
        .retry(DELETE_NUM_RETRIES)
        .exponentialBackoff(
            DELETE_MIN_RETRY_WAIT_MS,
            DELETE_MAX_RETRY_WAIT_MS,
            DELETE_TOTAL_RETRY_TIME_MS,
            2 /* exponential */)
        .run(
            path -> {
              io.deleteFile(path);
              deletedFilesCount.incrementAndGet();
            });

    if (deletedFilesCount.get() < paths.size()) {
      LOG.warn("Deleted only {} of {} file(s) ({})", deletedFilesCount, paths.size(), context);
    } else {
      LOG.info("Deleted {} file(s) ({})", paths.size(), context);
    }
  }
}

View on GitHub (pinned to 86d9c8fc54)

Solutions

  1. Check logs for the accompanying 'Failed to delete' warnings to see which paths failed and why
  2. Run the remove_orphan_files procedure to sweep remaining orphan files
  3. Fix underlying storage permissions or throttling issues
  4. Treat as benign when concurrent writers intentionally removed the files
Defensive patterns

Strategy: validation

Validate before calling

// after aborts, verify orphan files
CALL catalog.system.remove_orphan_files(table => 'db.t', older_than => TIMESTAMP '2026-09-10 00:00:00');

Prevention

When it happens

Trigger: deleteFiles path (abort cleanup, deleteWhere) counts increments only after successful io.deleteFile; any suppressed failures (including stopRetryOn NotFoundException) leave deletedFilesCount below paths.size().

Common situations: Orphan files left behind after aborted Spark jobs when some storage operations fail; concurrent writers deleting the same files (NotFoundException).

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/50ed426c9a7a7270. Report an issue: GitHub.