apache/flink · error · IllegalArgumentException
Native S3 File System cannot recover recoverable for other f
Error message
Native S3 File System cannot recover recoverable for other file system: {} What it means
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.
Source
Thrown at flink-filesystems/flink-s3-fs-native/src/main/java/org/apache/flink/fs/s3native/writer/NativeS3RecoverableWriter.java:222
return (SimpleVersionedSerializer) NativeS3RecoverableSerializer.INSTANCE;
}
@Override
@SuppressWarnings({"rawtypes", "unchecked"})
public SimpleVersionedSerializer<ResumeRecoverable> getResumeRecoverableSerializer() {
return (SimpleVersionedSerializer) NativeS3RecoverableSerializer.INSTANCE;
}
@Override
public boolean supportsResume() {
return true;
}
private static NativeS3Recoverable castToNativeS3Recoverable(CommitRecoverable recoverable) {
if (recoverable instanceof NativeS3Recoverable) {
return (NativeS3Recoverable) recoverable;
}
throw new IllegalArgumentException(
"Native S3 File System cannot recover recoverable for other file system: "
+ recoverable);
}
private static NativeS3Recoverable castToNativeS3Recoverable(ResumeRecoverable recoverable) {
if (recoverable instanceof NativeS3Recoverable) {
return (NativeS3Recoverable) recoverable;
}
throw new IllegalArgumentException(
"Native S3 File System cannot recover recoverable for other file system: "
+ recoverable);
}
@Override
public void close() {
if (!closed.compareAndSet(false, true)) {
return;
}View on GitHub (pinned to 2f3c205e92)
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.
Example fix
// before RecoverableWriter anyWriter = cachedWriter; // maybe from hdfs fs anyWriter.recoverForCommit(rec); // after RecoverableWriter s3Writer = outputPath.getFileSystem().createRecoverableWriter(); s3Writer.recoverForCommit(rec);
Defensive patterns
Strategy: type-guard
Type guard
static boolean isNativeS3Recoverable(CommitRecoverable r) {
return r instanceof org.apache.flink.fs.s3native.writer.NativeS3Recoverable;
} Try / catch
try {
writer.recoverForCommit(rec);
} catch (IllegalArgumentException e) {
// recoverable belongs to a different filesystem implementation
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Failed to get object for key: {}
- Incomplete-tail file does not exist: {}
- Cannot create local tmp dir: {}
- Input opening request timed out. Opener was {} alive. Stack
- Cannot sync state to system like S3. Use persist() to create
AI-assisted analysis of apache/flink@2f3c205e92 (2026-08-14).
Data as JSON: /api/errors/2ee1d65e9152fc81.
Report an issue: GitHub.