{"record":{"id":"ee6eb9700306624b","repo":"apache/iceberg","slug":"failed-to-delete-ee6eb9","errorCode":null,"errorMessage":"Failed to delete: {}","messagePattern":"Failed to delete: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"core/src/main/java/org/apache/iceberg/actions/RewriteDataFilesCommitManager.java","lineNumber":128,"sourceCode":"    }\n\n    rewrite.commit();\n  }\n\n  /**\n   * Clean up a specified file set by removing any files created for that operation, should not\n   * throw any exceptions\n   *\n   * @param fileGroup group of files which has already been rewritten\n   */\n  public void abortFileGroup(RewriteFileGroup fileGroup) {\n    Preconditions.checkState(\n        fileGroup.addedFiles() != null, \"Cannot abort a fileGroup that was not rewritten\");\n\n    Tasks.foreach(fileGroup.addedFiles())\n        .noRetry()\n        .suppressFailureWhenFinished()\n        .onFailure((dataFile, exc) -> LOG.warn(\"Failed to delete: {}\", dataFile.location(), exc))\n        .run(dataFile -> table.io().deleteFile(dataFile.location()));\n  }\n\n  public void commitOrClean(Set<RewriteFileGroup> rewriteGroups) {\n    try {\n      commitFileGroups(rewriteGroups);\n    } catch (CommitStateUnknownException e) {\n      LOG.error(\n          \"Commit state unknown for {}, cannot clean up files because they may have been committed successfully.\",\n          rewriteGroups,\n          e);\n      throw e;\n    } catch (Exception e) {\n      if (e instanceof CleanableFailure) {\n        LOG.error(\n            \"Cannot commit groups {}, attempting to clean up written files\", rewriteGroups, e);\n        rewriteGroups.forEach(this::abortFileGroup);\n      }","sourceCodeStart":110,"sourceCodeEnd":146,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/core/src/main/java/org/apache/iceberg/actions/RewriteDataFilesCommitManager.java#L110-L146","documentation":"WARN logged by RewriteDataFilesCommitManager.abortFileGroup when deleting the files added by a rewrite group whose commit failed. abortFileGroup is invoked after a failed or cancelled commit to remove the new data files; each delete failure is logged individually and suppressed so the whole cleanup pass completes.","triggerScenarios":"commitFileGroups fails (or is aborted), abortFileGroup runs Tasks.foreach over fileGroup.addedFiles(), and table.io().deleteFile(dataFile.location()) throws for at least one file.","commonSituations":"Object store permission errors or rate limiting during cleanup; file already deleted by a concurrent operation; transient network failure during bulk deletes.","solutions":["Read the chained cause in the WARN to find the delete error (ACL, throttling, missing file).","Verify table.io() credentials/permissions allow deletion in the table's data directory.","Re-run the rewrite; uncommitted leftovers can be cleaned with orphan file removal.","For 'already deleted' errors, no action needed — files were never referenced by a snapshot."],"exampleFix":"// before\ntable.io().deleteFile(dataFile.location());\n// after\ntry {\n  table.io().deleteFile(dataFile.location());\n} catch (RuntimeException e) {\n  LOG.warn(\"Skipping already-deleted file {}\", dataFile.location(), e);\n}","handlingStrategy":"fallback","validationCode":"// ensure table.io() supports deletion\ntry (// probe: table.io().deleteFile on a temp file in data dir if feasible) {}","typeGuard":null,"tryCatchPattern":"try {\n  rewrite.commit();\n} catch (Exception e) {\n  rewrite.abortFileGroups(); // deletes may warn; leftover files cleaned by expire orphans\n  throw e;\n}","preventionTips":["Use credentials with delete rights on the data directory.","Throttle object-store operations to avoid rate-limit failures during bulk delete.","Treat non-404 delete failures as actionable and investigate the chained cause."],"tags":["cleanup","file-deletion","rewrite"],"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-14T16:17:12.679Z"}