{"record":{"id":"4325a4bbcf25d103","repo":"apache/iceberg","slug":"failed-to-create-file-s","errorCode":null,"errorMessage":"Failed to create file: %s","messagePattern":"Failed to create file: (.+?)","errorType":"exception","errorClass":"NotFoundException","httpStatus":404,"severity":"error","filePath":"aliyun/src/main/java/org/apache/iceberg/aliyun/oss/OSSOutputStream.java","lineNumber":86,"sourceCode":"    this.stream = newStream(currentStagingFile);\n    this.writeBytes = metrics.counter(FileIOMetricsContext.WRITE_BYTES, Unit.BYTES);\n    this.writeOperations = metrics.counter(FileIOMetricsContext.WRITE_OPERATIONS);\n  }\n\n  private static File newStagingFile(String ossStagingDirectory) {\n    try {\n      File stagingFile = File.createTempFile(\"oss-file-io-\", \".tmp\", new File(ossStagingDirectory));\n      return stagingFile;\n    } catch (IOException e) {\n      throw new UncheckedIOException(e);\n    }\n  }\n\n  private static OutputStream newStream(File currentStagingFile) {\n    try {\n      return new BufferedOutputStream(new FileOutputStream(currentStagingFile));\n    } catch (FileNotFoundException e) {\n      throw new NotFoundException(e, \"Failed to create file: %s\", currentStagingFile);\n    }\n  }\n\n  private static InputStream uncheckedInputStream(File file) {\n    try {\n      return new FileInputStream(file);\n    } catch (IOException e) {\n      throw new UncheckedIOException(e);\n    }\n  }\n\n  @Override\n  public long getPos() {\n    return pos;\n  }\n\n  @Override\n  public void flush() throws IOException {","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/aliyun/src/main/java/org/apache/iceberg/aliyun/oss/OSSOutputStream.java#L68-L104","documentation":"OSSOutputStream stages written data in a local temporary file before uploading to OSS. newStream opens a FileOutputStream on that staging file; if the file cannot be created/opened (FileNotFoundException), it throws NotFoundException(\"Failed to create file: <path>\"). This is a local-disk problem, not an OSS problem.","triggerScenarios":"Constructing OSSOutputStream when the staging directory does not exist, is not writable, disk is full, or the temp path is invalid (permissions, read-only FS, missing parent dir).","commonSituations":"Containers with small/empty /tmp; java.io.tmpdir pointing to a read-only or removed directory; disk quota exceeded on executor nodes; running as a user without write permission to the staging dir.","solutions":["Ensure the local staging/tmp directory exists and is writable by the process user.","Set a valid java.io.tmpdir / staging location with free disk space.","Check disk usage and quotas on the node (df -h) and clean space if full.","Fix filesystem permissions (chmod/chown) on the staging directory."],"exampleFix":"// before\nspark-submit ... # tmpdir default may be unwritable\n\n// after\nspark-submit --conf spark.local.dir=/mnt/writable/spark-tmp \\\n  -Djava.io.tmpdir=/mnt/writable/tmp ...","handlingStrategy":"validation","validationCode":"Path tmp = Path.of(System.getProperty(\"java.io.tmpdir\"));\nif (!Files.isDirectory(tmp) || !Files.isWritable(tmp)) {\n  throw new IllegalStateException(\"Local staging dir not writable: \" + tmp);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Provision executors with adequate free disk and writable java.io.tmpdir.","Monitor disk usage (df) on nodes running OSS writes.","Run processes as users with write access to the staging directory.","Prefer local SSD scratch space for staging large files."],"tags":["aliyun","local-disk","fileio","file-not-found"],"backgroundTag":"file-not-found","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"}