apache/flink · error · IllegalArgumentException

LocalFileSystem cannot recover recoverable for other file sy

Error message

LocalFileSystem cannot recover recoverable for other file system: {}

What it means

Thrown by LocalRecoverableWriter.recover when the supplied ResumeRecoverable is not an instance of LocalRecoverable. The LocalFileSystem writer can only resume streams it originally created; passing a recoverable from a different filesystem (e.g. HdfsRecoverable, S3Recoverable) is a type error caught at runtime.

Source

Thrown at flink-core/src/main/java/org/apache/flink/core/fs/local/LocalRecoverableWriter.java:65

    public RecoverableFsDataOutputStream open(Path filePath) throws IOException {
        final File targetFile = fs.pathToFile(filePath);
        final File tempFile = generateStagingTempFilePath(targetFile);

        // try to create the parent
        final File parent = tempFile.getParentFile();
        if (parent != null && !parent.mkdirs() && !parent.exists()) {
            throw new IOException("Failed to create the parent directory: " + parent);
        }

        return new LocalRecoverableFsDataOutputStream(targetFile, tempFile);
    }

    @Override
    public RecoverableFsDataOutputStream recover(ResumeRecoverable recoverable) throws IOException {
        if (recoverable instanceof LocalRecoverable) {
            return new LocalRecoverableFsDataOutputStream((LocalRecoverable) recoverable);
        } else {
            throw new IllegalArgumentException(
                    "LocalFileSystem cannot recover recoverable for other file system: "
                            + recoverable);
        }
    }

    @Override
    public boolean requiresCleanupOfRecoverableState() {
        return false;
    }

    @Override
    public boolean cleanupRecoverableState(ResumeRecoverable resumable) throws IOException {
        return false;
    }

    @Override
    public Committer recoverForCommit(CommitRecoverable recoverable) throws IOException {
        if (recoverable instanceof LocalRecoverable) {

View on GitHub (pinned to 2f3c205e92)

Solutions

  1. Ensure the RecoverableFsDataOutputStream.Recoverable/ResumeRecoverable passed to recover was created by a LocalRecoverableFsDataOutputStream.
  2. Dispatch recovery through the correct writer for the filesystem that originally wrote the data.
  3. Add an instanceof check before calling recover to give a clearer error or skip.

Example fix

// before
RecoverableFsDataOutputStream out = localWriter.recover(recoverable);

// after — dispatch by recoverable type
RecoverableFsDataOutputStream out;
if (recoverable instanceof LocalRecoverable) {
    out = localWriter.recover(recoverable);
} else {
    out = matchingWriter.recover(recoverable);
}
Defensive patterns

Strategy: type-guard

Validate before calling

if (!(recoverable instanceof LocalRecoverable)) {
    throw new IllegalArgumentException("Expected LocalRecoverable, got " + recoverable.getClass());
}

Type guard

recoverable instanceof LocalRecoverable

Prevention

When it happens

Trigger: Calling LocalRecoverableWriter.recover(recoverable) where recoverable was produced by a non-local RecoverableFsDataOutputStream (HDFS, S3, etc.); mixing up writer instances across filesystem types in recovery logic.

Common situations: A job configured to use a remote filesystem (HDFS/S3) but recovery code mistakenly instantiates LocalRecoverableWriter; generic recovery code that does not dispatch on the filesystem type; testing with a local writer against data written by a distributed filesystem sink.

Related errors


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