{"record":{"id":"db7d01ce3e2f4784","repo":"apache/iceberg","slug":"failed-to-delete-db7d01","errorCode":null,"errorMessage":"Failed to delete {} ({})","messagePattern":"Failed to delete (.+?) \\((.+?)\\)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"spark/v4.2/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.2/spark/src/main/java/org/apache/iceberg/spark/source/SparkCleanupUtil.java#L83-L119","documentation":"Not a thrown exception but a WARN log emitted by SparkCleanupUtil.deleteFiles when the per-file delete task fails after retries. Tasks.foreach retries each path DELETE_NUM_RETRIES times with exponential backoff, stopping early only on NotFoundException; when a path still fails to delete, it is logged with the failure context. Orphan data files may be left behind and require an orphan-file cleanup procedure.","triggerScenarios":"Delete of data files during job/task abort where io.deleteFile(path) throws a transient or permanent IO exception (network blip to object store, credentials expiring mid-delete, throttling from S3/GCS, or a non-NotFoundException persistent error) after exhausting retries.","commonSituations":"Object-store throttling (S3 503s) during large aborts; expired cloud credentials on long-running jobs; files already deleted by a concurrent operation; misconfigured FileIO with wrong endpoint.","solutions":["Check the logged path and the wrapped exception cause for the actual delete error","Run an orphan-file cleanup (removeOrphanFiles) to remove any files left behind","Verify FileIO credentials/permissions are valid for the file locations","If caused by throttling, reduce delete parallelism or retry frequency"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Ensure FileIO credentials remain valid for the job duration","Pre-empt object-store throttling by reducing delete concurrency","Schedule periodic removeOrphanFiles to reconcile leaked files"],"tags":["spark","file-deletion","cleanup"],"backgroundTag":"file-delete-failed","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}