{"record":{"id":"c3827e6a7d18662e","repo":"apache/flink","slug":"file-not-found","errorCode":null,"errorMessage":"File Not Found: {}","messagePattern":"File Not Found: (.+?)","errorType":"exception","errorClass":"FileNotFoundException","httpStatus":null,"severity":"error","filePath":"flink-core/src/main/java/org/apache/flink/core/fs/local/LocalRecoverableFsDataOutputStream.java","lineNumber":70,"sourceCode":"\n    private final OutputStream fos;\n\n    public LocalRecoverableFsDataOutputStream(File targetFile, File tempFile) throws IOException {\n        this.targetFile = checkNotNull(targetFile);\n        this.tempFile = checkNotNull(tempFile);\n\n        this.fileChannel =\n                FileChannel.open(\n                        tempFile.toPath(), StandardOpenOption.WRITE, StandardOpenOption.CREATE_NEW);\n        this.fos = Channels.newOutputStream(fileChannel);\n    }\n\n    LocalRecoverableFsDataOutputStream(LocalRecoverable resumable) throws IOException {\n        this.targetFile = checkNotNull(resumable.targetFile());\n        this.tempFile = checkNotNull(resumable.tempFile());\n\n        if (!tempFile.exists()) {\n            throw new FileNotFoundException(\"File Not Found: \" + tempFile.getAbsolutePath());\n        }\n\n        this.fileChannel =\n                FileChannel.open(\n                        tempFile.toPath(), StandardOpenOption.WRITE, StandardOpenOption.APPEND);\n        if (this.fileChannel.position() < resumable.offset()) {\n            throw new IOException(\"Missing data in tmp file: \" + tempFile.getAbsolutePath());\n        }\n        this.fileChannel.truncate(resumable.offset());\n        this.fos = Channels.newOutputStream(fileChannel);\n    }\n\n    @VisibleForTesting\n    LocalRecoverableFsDataOutputStream(\n            File targetFile, File tempFile, FileChannel fileChannel, OutputStream fos) {\n        this.targetFile = checkNotNull(targetFile);\n        this.tempFile = checkNotNull(tempFile);\n        this.fileChannel = fileChannel;","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-core/src/main/java/org/apache/flink/core/fs/local/LocalRecoverableFsDataOutputStream.java#L52-L88","documentation":"Thrown as FileNotFoundException by the LocalRecoverableFsDataOutputStream recovery constructor when the temp file referenced by the LocalRecoverable does not exist on disk. Recovery cannot proceed without the temp file holding the in-progress data.","triggerScenarios":"Constructing `new LocalRecoverableFsDataOutputStream(resumable)` where resumable.tempFile() points to a file that has been deleted or never written on this node.","commonSituations":"Recovery on a different TaskManager node than the one that wrote the temp file (local FS temp files are not shared across nodes); temp dir cleaned between failure and recovery; temp file on a tmpfs/ramdisk that was cleared on restart.","solutions":["Use a shared/distributed filesystem for recoverable writer temp files when recovery may happen on a different node.","Ensure the local temp directory persists across TaskManager restarts (avoid /tmp on tmpfs).","If recovery data is genuinely lost, fall back to recomputing from the last successful checkpoint.","Pin task recovery to the same node via slot allocation when using local FS recovery."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"void ensureTempFileExists(LocalRecoverable r) throws IOException {\n    if (!r.tempFile().exists())\n        throw new FileNotFoundException(\"temp file missing, cannot recover: \" + r.tempFile());\n}","typeGuard":null,"tryCatchPattern":"try {\n    new LocalRecoverableFsDataOutputStream(resumable);\n} catch (FileNotFoundException e) {\n    // fall back to last checkpoint; local temp is node-specific\n}","preventionTips":["Use shared filesystem for temp files when recovery may move nodes.","Keep temp dir off tmpfs/ramdisk that clears on restart.","Pin recoverable tasks to the originating node where possible."],"tags":["filesystem","local-fs","recoverable-writer","recovery","file-not-found"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}