{"record":{"id":"6b0f1e646982b65e","repo":"apache/iceberg","slug":"failed-to-delete-6b0f1e","errorCode":null,"errorMessage":"Failed to delete {} ({})","messagePattern":"Failed to delete (.+?) \\((.+?)\\)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"spark/v4.0/spark/src/main/java/org/apache/iceberg/spark/source/SparkCleanupUtil.java","lineNumber":101,"sourceCode":"   * @param files a list of files to delete\n   */\n  public static void deleteFiles(String context, FileIO io, List<? extends ContentFile<?>> files) {\n    List<String> paths = Lists.transform(files, ContentFile::location);\n    if (io instanceof SupportsBulkOperations) {\n      CatalogUtil.deleteFiles(io, paths, \"\");\n    } else {\n      delete(context, io, paths);\n    }\n  }\n\n  private static void delete(String context, FileIO io, List<String> paths) {\n    AtomicInteger deletedFilesCount = new AtomicInteger(0);\n\n    Tasks.foreach(paths)\n        .executeWith(ThreadPools.getWorkerPool())\n        .stopRetryOn(NotFoundException.class)\n        .suppressFailureWhenFinished()\n        .onFailure((path, exc) -> LOG.warn(\"Failed to delete {} ({})\", path, context, exc))\n        .retry(DELETE_NUM_RETRIES)\n        .exponentialBackoff(\n            DELETE_MIN_RETRY_WAIT_MS,\n            DELETE_MAX_RETRY_WAIT_MS,\n            DELETE_TOTAL_RETRY_TIME_MS,\n            2 /* exponential */)\n        .run(\n            path -> {\n              io.deleteFile(path);\n              deletedFilesCount.incrementAndGet();\n            });\n\n    if (deletedFilesCount.get() < paths.size()) {\n      LOG.warn(\"Deleted only {} of {} file(s) ({})\", deletedFilesCount, paths.size(), context);\n    } else {\n      LOG.info(\"Deleted {} file(s) ({})\", paths.size(), context);\n    }\n  }","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v4.0/spark/src/main/java/org/apache/iceberg/spark/source/SparkCleanupUtil.java#L83-L119","documentation":"SparkCleanupUtil.deleteFiles deletes files in parallel via Tasks.foreach with retries and exponential backoff. When a file still fails to delete after all retries (excluding NotFoundException, which is treated as success), it logs which path failed and why. This typically happens during abort cleanup of a Spark write job; leftover files usually have no impact on table correctness.","triggerScenarios":"A transient or persistent storage error (permissions, throttling, network) during abort-time deletion of uncommitted data files; retried DELETE_NUM_RETRIES times with backoff before this warning.","commonSituations":"S3/GCS rate limiting (429/503) under heavy parallel deletes; stale credentials or revoked permissions on the job's identity; concurrent cleanup by another process already removed files with a non-NotFoundException error.","solutions":["Check the embedded exception for the root cause (permissions, throttling, network).","Manually delete orphaned files afterward with remove_orphan_files.","Retry the aborted job; deletion is retried internally with backoff, but persistent issues need the storage problem fixed."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"boolean canDelete = io.deleteFile != null; // ensure credentials/permissions valid before job start","typeGuard":null,"tryCatchPattern":"try { io.deleteFile(path); } catch (UncheckedIOException e) { log.warn(\"Leftover file {} to clean later\", path, e); }","preventionTips":["Verify write/delete permissions for the job identity before large writes.","Avoid delete storms that trigger object-store throttling; pace concurrency.","Run remove_orphan_files on a schedule to sweep leftovers."],"tags":["fileio","delete","cleanup","storage"],"backgroundTag":"file-write-failed","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}