{"record":{"id":"2afa43d4bb02ed34","repo":"apache/iceberg","slug":"failed-to-get-deleted-files-this-may-cause-orphan-2afa43","errorCode":null,"errorMessage":"Failed to get deleted files: this may cause orphaned data files","messagePattern":"Failed to get deleted files: this may cause orphaned data files","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"core/src/main/java/org/apache/iceberg/IncrementalFileCleanup.java","lineNumber":294,"sourceCode":"          expiredStatisticsFilesLocations(beforeExpiration, afterExpiration);\n      LOG.debug(\"Deleting {} statistics files\", expiredStatisticsFilesLocations.size());\n      deleteFiles(expiredStatisticsFilesLocations, \"statistics files\");\n    }\n  }\n\n  private Set<String> findFilesToDelete(\n      Set<ManifestFile> manifestsToScan,\n      Set<ManifestFile> manifestsToRevert,\n      Set<Long> validIds,\n      Map<Integer, PartitionSpec> specsById) {\n    Set<String> filesToDelete = ConcurrentHashMap.newKeySet();\n    Tasks.foreach(manifestsToScan)\n        .retry(3)\n        .suppressFailureWhenFinished()\n        .executeWith(planExecutorService)\n        .onFailure(\n            (item, exc) ->\n                LOG.warn(\"Failed to get deleted files: this may cause orphaned data files\", exc))\n        .run(\n            manifest -> {\n              // the manifest has deletes, scan it to find files to delete\n              try (ManifestReader<?> reader = ManifestFiles.open(manifest, fileIO, specsById)) {\n                for (ManifestEntry<?> entry : reader.entries()) {\n                  // if the snapshot ID of the DELETE entry is no longer valid, the data can be\n                  // deleted\n                  if (entry.status() == ManifestEntry.Status.DELETED\n                      && !validIds.contains(entry.snapshotId())) {\n                    // use toString to ensure the path will not change (Utf8 is reused)\n                    filesToDelete.add(entry.file().location());\n                  }\n                }\n              } catch (IOException e) {\n                throw new RuntimeIOException(e, \"Failed to read manifest file: %s\", manifest);\n              }\n            });\n","sourceCodeStart":276,"sourceCodeEnd":312,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/core/src/main/java/org/apache/iceberg/IncrementalFileCleanup.java#L276-L312","documentation":"During incremental cleanup, findFilesToDelete scans manifests with DELETE entries in parallel to compute deleted data files. If scanning a manifest fails (after 3 retries), this WARN 'Failed to get deleted files: this may cause orphaned data files' is logged. Because the failed manifest's DELETE entries are unknown, files that should be expired may be left as orphans.","triggerScenarios":"filesToDelete -> findFilesToDelete opens a ManifestReader (ManifestFiles.open) for each manifest to scan and iterates entries; a manifest object is unreadable/corrupted, or the IO throws transiently, for manifests flagged as having deletes.","commonSituations":"Manifests deleted or unreadable due to eventual consistency after concurrent expiration; corrupt manifests from a failed write; missing object-store read permissions; throttling under parallel planning.","solutions":["Check the WARN cause and verify the manifest file exists and is readable via the FileIO.","Do not run concurrent expirations; rerun expiration later so missed manifests are scanned then.","Plan a full (non-incremental) cleanup or an orphan-file removal to catch files skipped by this run.","Increase retry robustness (check network/config) if throttling is the cause."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// verify manifests referenced by snapshots are readable before cleanup\nValidationHelpers.checkManifestsReadable(table, io); // custom check opening each manifest","typeGuard":null,"tryCatchPattern":"try {\n  table.expireSnapshots().execute();\n} catch (RuntimeException e) {\n  LOG.warn(\"Some manifests could not be scanned; orphan sweep recommended\", e);\n}","preventionTips":["Schedule periodic remove-orphan-files to reclaim files skipped by failed manifest scans.","Avoid overlapping maintenance tasks deleting manifests mid-run.","Monitor for corrupted manifests after failed writes and repair via table recovery.","Confirm read permissions on all manifest paths."],"tags":["cleanup","manifests","io","orphaned-files"],"backgroundTag":"file-read-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"}