apache/flink · error · FileNotFoundException

File Not Found: {}

Error message

File Not Found: {}

What it means

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.

Source

Thrown at flink-core/src/main/java/org/apache/flink/core/fs/local/LocalRecoverableFsDataOutputStream.java:70

    private final OutputStream fos;

    public LocalRecoverableFsDataOutputStream(File targetFile, File tempFile) throws IOException {
        this.targetFile = checkNotNull(targetFile);
        this.tempFile = checkNotNull(tempFile);

        this.fileChannel =
                FileChannel.open(
                        tempFile.toPath(), StandardOpenOption.WRITE, StandardOpenOption.CREATE_NEW);
        this.fos = Channels.newOutputStream(fileChannel);
    }

    LocalRecoverableFsDataOutputStream(LocalRecoverable resumable) throws IOException {
        this.targetFile = checkNotNull(resumable.targetFile());
        this.tempFile = checkNotNull(resumable.tempFile());

        if (!tempFile.exists()) {
            throw new FileNotFoundException("File Not Found: " + tempFile.getAbsolutePath());
        }

        this.fileChannel =
                FileChannel.open(
                        tempFile.toPath(), StandardOpenOption.WRITE, StandardOpenOption.APPEND);
        if (this.fileChannel.position() < resumable.offset()) {
            throw new IOException("Missing data in tmp file: " + tempFile.getAbsolutePath());
        }
        this.fileChannel.truncate(resumable.offset());
        this.fos = Channels.newOutputStream(fileChannel);
    }

    @VisibleForTesting
    LocalRecoverableFsDataOutputStream(
            File targetFile, File tempFile, FileChannel fileChannel, OutputStream fos) {
        this.targetFile = checkNotNull(targetFile);
        this.tempFile = checkNotNull(tempFile);
        this.fileChannel = fileChannel;

View on GitHub (pinned to 2f3c205e92)

Solutions

  1. Use a shared/distributed filesystem for recoverable writer temp files when recovery may happen on a different node.
  2. Ensure the local temp directory persists across TaskManager restarts (avoid /tmp on tmpfs).
  3. If recovery data is genuinely lost, fall back to recomputing from the last successful checkpoint.
  4. Pin task recovery to the same node via slot allocation when using local FS recovery.
Defensive patterns

Strategy: validation

Validate before calling

void ensureTempFileExists(LocalRecoverable r) throws IOException {
    if (!r.tempFile().exists())
        throw new FileNotFoundException("temp file missing, cannot recover: " + r.tempFile());
}

Try / catch

try {
    new LocalRecoverableFsDataOutputStream(resumable);
} catch (FileNotFoundException e) {
    // fall back to last checkpoint; local temp is node-specific
}

Prevention

When it happens

Trigger: Constructing `new LocalRecoverableFsDataOutputStream(resumable)` where resumable.tempFile() points to a file that has been deleted or never written on this node.

Common situations: 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.

Related errors


AI-assisted analysis of apache/flink@2f3c205e92 (2026-08-14). Data as JSON: /api/errors/c3827e6a7d18662e. Report an issue: GitHub.