{"record":{"id":"71d61b3cc0c23c62","repo":"prestodb/presto","slug":"iceberg-filesystem-error-71d61b","errorCode":"ICEBERG_FILESYSTEM_ERROR","errorMessage":"Failed to delete file: ${path}","messagePattern":"Failed to delete file: (.+?)","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-iceberg/src/main/java/com/facebook/presto/iceberg/HdfsFileIO.java","lineNumber":85,"sourceCode":"                new HdfsCachedInputFile(inputFile, new ManifestFileCacheKey(manifest.path()), manifestFileCache) :\n                inputFile;\n    }\n\n    @Override\n    public OutputFile newOutputFile(String path)\n    {\n        return new HdfsOutputFile(new Path(path), environment, context);\n    }\n\n    @Override\n    public void deleteFile(String pathString)\n    {\n        Path path = new Path(pathString);\n        try {\n            environment.doAs(context.getIdentity().getUser(), () -> environment.getFileSystem(context, path).delete(path, false));\n        }\n        catch (IOException e) {\n            throw new PrestoException(ICEBERG_FILESYSTEM_ERROR, \"Failed to delete file: \" + path, e);\n        }\n    }\n\n    protected InputFile newCachedInputFile(String path)\n    {\n        InputFile inputFile = new HdfsInputFile(new Path(path), environment, context);\n        return manifestFileCache.isEnabled() ?\n                new HdfsCachedInputFile(inputFile, new ManifestFileCacheKey(path), manifestFileCache) :\n                inputFile;\n    }\n}\n","sourceCodeStart":67,"sourceCodeEnd":97,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-iceberg/src/main/java/com/facebook/presto/iceberg/HdfsFileIO.java#L67-L97","documentation":"HdfsFileIO.deleteFile deletes a file (non-recursive) through Hadoop's FileSystem within the configured HdfsEnvironment doAs block. On IOException the operation is wrapped in a PrestoException with code ICEBERG_FILESYSTEM_ERROR, meaning the underlying filesystem refused or failed the delete.","triggerScenarios":"Deleting a data/metadata file (e.g. Iceberg cleanup, delete orphans) when the HDFS/object-store delete call throws IOException: permission denied for the delegated user, file already gone with no idempotency, unknown host/Namenode errors, or object-store failures (S3 403/404 mapped to IOException).","commonSituations":"Wrong HDFS permissions/impersonation config, files deleted concurrently by another job, S3 credentials lacking delete permission, network partition to Namenode or object store.","solutions":["Check that the Presto service user (or impersonated user) has delete permission on the path; fix HDFS ACLs or object-store IAM policy.","Confirm the file still exists and is not locked/being deleted concurrently; retry after the competing job finishes.","Validate HdfsEnvironment/impersonation configuration (fs permissions, doAs settings).","Fix connectivity to the Namenode/object store (DNS, network) indicated in the wrapped IOException cause."],"exampleFix":"// before\nio.deleteFile(pathString);\n// after: guard with existence + retry\nFileSystem fs = environment.getFileSystem(context, new Path(pathString));\nif (fs.exists(new Path(pathString))) { io.deleteFile(pathString); }","handlingStrategy":"try-catch","validationCode":"Path p = new Path(pathString);\nFileSystem fs = environment.getFileSystem(context, p);\nif (!fs.exists(p)) return; // nothing to delete\nfs.access check / hdfs dfs -test -w path","typeGuard":"boolean canDelete(HdfsContext ctx, String path) { try { return environment.getFileSystem(ctx, new Path(path)).exists(new Path(path)); } catch (IOException e) { return false; } }","tryCatchPattern":"try { fileIo.deleteFile(path); } catch (PrestoException e) { if (e.getErrorCode().getName().contains(\"FILESYSTEM_ERROR\")) { log.warn(\"delete failed: \" + path, e); /* retry or mark for cleanup */ } else throw e; }","preventionTips":["Grant the Presto service/impersonated user delete rights on table locations","Make cleanup jobs idempotent — tolerate already-deleted files","Align orphan-file retention with active query durations","Monitor object-store IAM/HDFS ACL changes before maintenance windows"],"tags":["filesystem","hdfs","delete","permissions"],"backgroundTag":"filesystem-delete-failed","analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}