apache/iceberg · warning
Failed to get deleted files: this may cause orphaned data fi
Error message
Failed to get deleted files: this may cause orphaned data files
What it means
A WARN logged via Tasks' onFailure callback while CatalogUtil.deleteFiles scans manifests in parallel to collect files that are safe to delete after a table drop. If reading a manifest fails, the set of deleted files is incomplete — files referenced by the failed manifest will NOT be deleted, resulting in orphaned data/manifest files. The drop itself still proceeds; this warning signals storage leak, not data loss for surviving tables.
Source
Thrown at core/src/main/java/org/apache/iceberg/CatalogUtil.java:178
if (gcEnabled) {
deleteFile(io, metadata.metadataFileLocation(), "metadata");
}
}
@SuppressWarnings("DangerousStringInternUsage")
private static void deleteFiles(
FileIO io, Set<ManifestFile> allManifests, Map<Integer, PartitionSpec> specsById) {
// keep track of deleted files in a map that can be cleaned up when memory runs low
Map<String, Boolean> deletedFiles =
new MapMaker().concurrencyLevel(ThreadPools.WORKER_THREAD_POOL_SIZE).weakKeys().makeMap();
Tasks.foreach(allManifests)
.noRetry()
.suppressFailureWhenFinished()
.executeWith(ThreadPools.getWorkerPool())
.onFailure(
(item, exc) ->
LOG.warn("Failed to get deleted files: this may cause orphaned data files", exc))
.run(
manifest -> {
try (ManifestReader<?> reader = ManifestFiles.open(manifest, io, specsById)) {
List<String> pathsToDelete = Lists.newArrayList();
for (ManifestEntry<?> entry : reader.entries()) {
// intern the file path because the weak key map uses identity (==) instead of
// equals
String path = entry.file().location().intern();
Boolean alreadyDeleted = deletedFiles.putIfAbsent(path, true);
if (alreadyDeleted == null || !alreadyDeleted) {
pathsToDelete.add(path);
}
}
String type = reader.isDeleteManifestReader() ? "delete" : "data";
deleteFiles(io, pathsToDelete, type, false);
} catch (IOException e) {
throw new RuntimeIOException(View on GitHub (pinned to 86d9c8fc54)
Solutions
- Re-run the drop with the table's metadata intact, or manually list and delete the files referenced by the failed manifests.
- Fix storage permissions (FileIO credentials) so all manifests under the metadata location are readable.
- Check object-store lifecycle rules so manifests are not deleted before the table is dropped.
- Use the platform's orphan-file cleanup (e.g. Spark deleteOrphanFiles) to remove the leaked files.
Example fix
// before: drop fails silently leaving orphans
catalog.dropTable(identifier);
// after: sweep orphans afterwards
if (!catalog.tableExists(identifier)) {
SparkActions.get().deleteOrphanFiles(spark, "s3://bucket/db/tbl").execute();
} Defensive patterns
Strategy: fallback
Validate before calling
// ensure manifests readable before drop allManifests.forEach(m -> ManifestFiles.read(m, io).close());
Try / catch
try { catalog.dropTable(identifier); } finally { scheduleOrphanFileSweep(tableLocation); } Prevention
- Run deleteOrphanFiles after drops to catch leaked files
- Keep manifest files under the table location (not external paths)
- Avoid lifecycle rules that delete files before the table is dropped
- Grant delete/read permissions uniformly on the table prefix
When it happens
Trigger: dropTableData or deleteRemovedMetadataFiles triggers parallel manifest reads; a manifest file is unreadable — deleted/corrupted in object storage, missing permissions, missing spec entry (specsById mismatch), or transient S3/GCS errors.
Common situations: Table partially corrupted by a prior failed cleanup; IAM/permission changes between metadata read and manifest read; lifecycle policies deleting manifest files early; cross-region storage issues.
Understand the failure class
Background: "failed to read file", EACCES, ENOENT and "could not read <path>" errors: when a program can't read a file from disk — this error's family across 49 libraries.
Related errors
- Failed to read manifest file: %s
- Failed to validate replaced partitions
- Failed to write manifest
- Failed to read manifest file: %s
- Failed to read manifest file: %s
AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12).
Data as JSON: /api/errors/07d70234a09a53d6.
Report an issue: GitHub.