{"record":{"id":"ff6702c0e7f62076","repo":"prestodb/presto","slug":"iceberg-filesystem-error-ff6702","errorCode":"ICEBERG_FILESYSTEM_ERROR","errorMessage":"Failed to create output file: ${path.toString()}","messagePattern":"Failed to create output file: (.+?)","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-iceberg/src/main/java/com/facebook/presto/iceberg/HdfsOutputFile.java","lineNumber":48,"sourceCode":"public class HdfsOutputFile\n        implements OutputFile\n{\n    private final OutputFile delegate;\n    private final Path path;\n    private final HdfsEnvironment environment;\n    private final HdfsContext context;\n    private final String user;\n\n    public HdfsOutputFile(Path path, HdfsEnvironment environment, HdfsContext context)\n    {\n        this.path = requireNonNull(path, \"path is null\");\n        this.environment = requireNonNull(environment, \"environment is null\");\n        this.context = requireNonNull(context, \"context is null\");\n        try {\n            this.delegate = HadoopOutputFile.fromPath(path, environment.getFileSystem(context, path), environment.getConfiguration(context, path));\n        }\n        catch (IOException e) {\n            throw new PrestoException(ICEBERG_FILESYSTEM_ERROR, \"Failed to create output file: \" + path.toString(), e);\n        }\n        this.user = context.getIdentity().getUser();\n    }\n\n    @Override\n    public PositionOutputStream create()\n    {\n        return environment.doAs(user, delegate::create);\n    }\n\n    @Override\n    public PositionOutputStream createOrOverwrite()\n    {\n        return environment.doAs(user, delegate::createOrOverwrite);\n    }\n\n    @Override\n    public String location()","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-iceberg/src/main/java/com/facebook/presto/iceberg/HdfsOutputFile.java#L30-L66","documentation":"HdfsOutputFile's constructor creates a HadoopOutputFile delegate for the target path. An IOException there is wrapped in a PrestoException with code ICEBERG_FILESYSTEM_ERROR ('Failed to create output file'), signaling the filesystem could not prepare the destination — typically permissions, missing parent directory, or storage connectivity.","triggerScenarios":"Constructing HdfsOutputFile during Iceberg writes (commit metadata, new data files) when HadoopOutputFile.fromPath throws IOException: parent directory missing, permission denied, quota exceeded, or object-store put/create failing due to credentials.","commonSituations":"Table location directory deleted or not pre-created (HDFS does not auto-create parents), write permission missing for Presto user, HDFS disk quota exceeded, S3 bucket policy denying PutObject.","solutions":["Create the missing parent directory and grant write permission to the Presto user (hdfs dfs -mkdir -p / -chown / -chmod).","Check HDFS quota (hdfs dfs -count -q) and free space or raise the quota.","Verify object-store credentials/bucket policy allow writes at the target location.","Inspect the wrapped IOException cause to distinguish not-found vs permission vs quota vs connectivity."],"exampleFix":"// before: writing into a location whose directory was removed\n// after: ensure directory exists before write\nPath dir = new Path(tableLocation);\nFileSystem fs = environment.getFileSystem(context, dir);\nif (!fs.exists(dir)) { fs.mkdirs(dir); }\nOutputFile out = new HdfsOutputFile(new Path(tableLocation, \"metadata.json\"), environment, context);","handlingStrategy":"validation","validationCode":"Path dir = new Path(tableLocation);\nFileSystem fs = environment.getFileSystem(context, dir);\nif (!fs.exists(dir)) fs.mkdirs(dir);\n// and verify writability\nPath probe = new Path(dir, \".presto_probe\"); fs.create(probe).close(); fs.delete(probe, false);","typeGuard":"boolean canWrite(HdfsContext ctx, Path dir) { try { FileSystem fs = environment.getFileSystem(ctx, dir); return fs.exists(dir) && fs.mkdirs(dir); } catch (IOException e) { return false; } }","tryCatchPattern":"try { OutputFile out = new HdfsOutputFile(path, env, ctx); } catch (PrestoException e) { if (e.getCause() instanceof IOException) { ensureParentDir(path); /* retry once */ } throw e; }","preventionTips":["Pre-create table/base directories with correct ownership for the Presto user","Check HDFS quotas and object-store write policies before bulk loads","Keep filesystem configs (credentials, endpoints) valid for all workers","Run write-path smoke tests after storage or permission changes"],"tags":["filesystem","hdfs","output-file","permissions"],"backgroundTag":"filesystem-create-failed","analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-12T02:17:10.037Z"}