{"record":{"id":"53bdfb004a03b6bf","repo":"apache/iceberg","slug":"deleted-only-of-files-using-bulk-deletes","errorCode":null,"errorMessage":"Deleted only {} of {} files using bulk deletes","messagePattern":"Deleted only (.+?) of (.+?) files using bulk deletes","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/actions/DeleteOrphanFilesSparkAction.java","lineNumber":325,"sourceCode":"  }\n\n  private void collectPathsForOutput(\n      List<String> paths, List<String> orphanFileList, int maxSampleSize) {\n    if (streamResults()) {\n      int lengthToAdd = Math.min(maxSampleSize - orphanFileList.size(), paths.size());\n      orphanFileList.addAll(paths.subList(0, lengthToAdd));\n    } else {\n      orphanFileList.addAll(paths);\n    }\n  }\n\n  private void deleteBulk(SupportsBulkOperations io, List<String> paths) {\n    try {\n      io.deleteFiles(paths);\n      LOG.info(\"Deleted {} files using bulk deletes\", paths.size());\n    } catch (BulkDeletionFailureException e) {\n      int deletedFilesCount = paths.size() - e.numberFailedObjects();\n      LOG.warn(\n          \"Deleted only {} of {} files using bulk deletes\", deletedFilesCount, paths.size(), e);\n    }\n  }\n\n  private void deleteNonBulk(List<String> paths) {\n    Tasks.Builder<String> deleteTasks =\n        Tasks.foreach(paths)\n            .noRetry()\n            .executeWith(deleteExecutorService)\n            .suppressFailureWhenFinished()\n            .onFailure((file, exc) -> LOG.warn(\"Failed to delete file: {}\", file, exc));\n\n    if (deleteFunc == null) {\n      LOG.info(\n          \"Table IO {} does not support bulk operations. Using non-bulk deletes.\",\n          table.io().getClass().getName());\n      deleteTasks.run(table.io()::deleteFile);\n    } else {","sourceCodeStart":307,"sourceCodeEnd":343,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/actions/DeleteOrphanFilesSparkAction.java#L307-L343","documentation":"DeleteOrphanFilesSparkAction uses the FileIO's bulk delete API when supported. If the object store reports that some objects in the bulk request failed (BulkDeletionFailureException carries the failed count), the action logs this warning with how many of the total paths were actually deleted rather than throwing.","triggerScenarios":"Calling DeleteOrphanFiles (RemoveOrphanFiles) against a FileIO implementing SupportsBulkOperations (e.g. S3FileIO) where io.deleteFiles(paths) partially fails, raising BulkDeletionFailureException with numberFailedObjects > 0.","commonSituations":"S3 multi-object delete partial failures; objects locked by retention policies (Object Lock) that cannot be removed; transient object-store errors during large bulk batches.","solutions":["Re-run the DeleteOrphanFiles action — remaining older-than-threshold files will be retried.","Lower the batch size / concurrency of the S3FileIO if throttling causes partial failures.","Check bucket retention/Object Lock and versioning settings for objects that permanently refuse deletion.","If guaranteed cleanup is required, force the non-bulk path by using a FileIO without bulk support or by deleting the reported paths individually."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"if (table.io() instanceof SupportsBulkOperations) { /* bulk path: expect partial failures */ }","typeGuard":"if (table.io() instanceof SupportsBulkOperations bulkIo) { bulkIo.deleteFiles(paths); }","tryCatchPattern":null,"preventionTips":["Re-run DeleteOrphanFiles periodically to retry partially deleted batches.","Check S3 Object Lock/retention policies that block deletion.","Reduce bulk batch sizes if the object store throttles large requests."],"tags":["spark","orphan-file-cleanup","s3","bulk-delete"],"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"}