{"record":{"id":"2ee1d65e9152fc81","repo":"apache/flink","slug":"native-s3-file-system-cannot-recover-recoverable-f","errorCode":null,"errorMessage":"Native S3 File System cannot recover recoverable for other file system: {}","messagePattern":"Native S3 File System cannot recover recoverable for other file system: (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"flink-filesystems/flink-s3-fs-native/src/main/java/org/apache/flink/fs/s3native/writer/NativeS3RecoverableWriter.java","lineNumber":222,"sourceCode":"        return (SimpleVersionedSerializer) NativeS3RecoverableSerializer.INSTANCE;\n    }\n\n    @Override\n    @SuppressWarnings({\"rawtypes\", \"unchecked\"})\n    public SimpleVersionedSerializer<ResumeRecoverable> getResumeRecoverableSerializer() {\n        return (SimpleVersionedSerializer) NativeS3RecoverableSerializer.INSTANCE;\n    }\n\n    @Override\n    public boolean supportsResume() {\n        return true;\n    }\n\n    private static NativeS3Recoverable castToNativeS3Recoverable(CommitRecoverable recoverable) {\n        if (recoverable instanceof NativeS3Recoverable) {\n            return (NativeS3Recoverable) recoverable;\n        }\n        throw new IllegalArgumentException(\n                \"Native S3 File System cannot recover recoverable for other file system: \"\n                        + recoverable);\n    }\n\n    private static NativeS3Recoverable castToNativeS3Recoverable(ResumeRecoverable recoverable) {\n        if (recoverable instanceof NativeS3Recoverable) {\n            return (NativeS3Recoverable) recoverable;\n        }\n        throw new IllegalArgumentException(\n                \"Native S3 File System cannot recover recoverable for other file system: \"\n                        + recoverable);\n    }\n\n    @Override\n    public void close() {\n        if (!closed.compareAndSet(false, true)) {\n            return;\n        }","sourceCodeStart":204,"sourceCodeEnd":240,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-filesystems/flink-s3-fs-native/src/main/java/org/apache/flink/fs/s3native/writer/NativeS3RecoverableWriter.java#L204-L240","documentation":"castToNativeS3Recoverable(CommitRecoverable) throws IllegalArgumentException when the recoverable handed to recoverForCommit is not a NativeS3Recoverable. Each RecoverableWriter implementation owns its own recoverable type; passing one minted by a different filesystem (HDFS, s3p/hadoop-based, local) is a type error caught by an instanceof check.","triggerScenarios":"Calling NativeS3RecoverableWriter.recoverForCommit(commitRecoverable) with a CommitRecoverable produced by another writer — e.g. mixing writers from different FileSystem schemes in one sink, or deserializing a recoverable with the wrong serializer and feeding it to this writer.","commonSituations":"Job code that caches one RecoverableWriter but switches output paths across schemes (s3:// vs s3a:// vs hdfs://); state restored from a job that previously used a different S3 filesystem flavor (presto/hadoop vs native); serializer mix-ups where the wrong SimpleVersionedSerializer decoded the bytes.","solutions":["Acquire the RecoverableWriter from the same FileSystem/Path that created the stream (fs.createRecoverableWriter() on the s3-native filesystem), never a cached cross-scheme writer.","If migrating from another S3 filesystem implementation, discard old recoverable state — commit recoverables are not portable between implementations.","Add an instanceof check or use the writer tied to the output Path's scheme so mismatches fail with a clear upstream message.","Verify which plugin (flink-s3-fs-native vs flink-s3-fs-hadoop vs flink-s3-fs-presto) is loaded in lib/ for the scheme alias you use."],"exampleFix":"// before\nRecoverableWriter anyWriter = cachedWriter; // maybe from hdfs fs\nanyWriter.recoverForCommit(rec);\n\n// after\nRecoverableWriter s3Writer = outputPath.getFileSystem().createRecoverableWriter();\ns3Writer.recoverForCommit(rec);","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"static boolean isNativeS3Recoverable(CommitRecoverable r) {\n    return r instanceof org.apache.flink.fs.s3native.writer.NativeS3Recoverable;\n}","tryCatchPattern":"try {\n    writer.recoverForCommit(rec);\n} catch (IllegalArgumentException e) {\n    // recoverable belongs to a different filesystem implementation\n}","preventionTips":["Always pair writer and recoverable from the same filesystem scheme.","Load exactly one S3 plugin so scheme aliases resolve deterministically.","Never resume across S3 implementations."],"tags":["s3","type-mismatch","filesystem","recovery","config"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}