Flink write iceberg bug(org.apache.iceberg.exceptions.NotFoundException)
Apache Iceberg version
0.14.0
Query engine
Flink
Please describe the bug 🐞
When I use flink datastream api to write to iceberg, I sometimes report an error eg: org.apache.iceberg.exceptions.NotFoundException: Failed to open input stream for file: hdfs://master01-test.cndatacom.com:8020/edata/crop_prod/ods_t_history_regist_capis_1g/metadata/snap-8702477485757278341-1-b7bbce1a-6459-4c64-9689-4b88453db9cd.avro ,Then I try to query the table and report the error
Could you please share the full Exception, and the Flink version what is used in your case? Thanks, Peter
Could you please share the full Exception, and the Flink version what is used in your case? Thanks, Peter
used Flink version 1.13.6 and iceberg version 0.14.0
org.apache.iceberg.exceptions.RuntimeIOException: Failed to write json to file: hdfs://master01-test.cndatacom.com:8020/edata/crop_prod/ods_t_enterprise_investment_1g/metadata/1cf4953b-9a63-4156-b365-a4950b93e1d0.metadata.json
@95liu: OK, I wasn't clear enough. I would like to see the whole stack trace. Also, in the previous error message was for an avro file, now it is for a json file. Have you checked the health of the HDFS, or any transient error there, or on the network?
We meet this issue in these two situations:
- No access permission
- write metadata into wrong HDFS location
Any failover happen? There's antother file not found exception reported in #6066
Has anyone else encountered this with Hive Iceberg runtime , as well? It appears to have propagated to 1.1 but it's not there in 0.13.2.
Yes i am using spark structured streaming to commit data into iceberg. i am also getting same exceptions intermediately.
Caused by: org.apache.iceberg.exceptions.NotFoundException: Failed to open input stream for file: s3a://XXXXXXXX/metadata/snap-6961165512118673576-2-a7c254f8-d3d8-415b-bf10-e9b1bdf8d241.avro at org.apache.iceberg.hadoop.HadoopInputFile.newStream(HadoopInputFile.java:185) at org.apache.iceberg.avro.AvroIterable.newFileReader(AvroIterable.java:100) at org.apache.iceberg.avro.AvroIterable.iterator(AvroIterable.java:76) at org.apache.iceberg.avro.AvroIterable.iterator(AvroIterable.java:36) at org.apache.iceberg.relocated.com.google.common.collect.Iterables.addAll(Iterables.java:337) at org.apache.iceberg.relocated.com.google.common.collect.Lists.newLinkedList(Lists.java:241) at org.apache.iceberg.ManifestLists.read(ManifestLists.java:45) at org.apache.iceberg.BaseSnapshot.cacheManifests(BaseSnapshot.java:148) at org.apache.iceberg.BaseSnapshot.dataManifests(BaseSnapshot.java:174) at org.apache.iceberg.MergingSnapshotProducer.apply(MergingSnapshotProducer.java:780) at org.apache.iceberg.SnapshotProducer.apply(SnapshotProducer.java:223) at org.apache.iceberg.SnapshotProducer.lambda$commit$2(SnapshotProducer.java:369) at org.apache.iceberg.util.Tasks$Builder.runTaskWithRetry(Tasks.java:402) at org.apache.iceberg.util.Tasks$Builder.runSingleThreaded(Tasks.java:212) at org.apache.iceberg.util.Tasks$Builder.run(Tasks.java:196) at org.apache.iceberg.util.Tasks$Builder.run(Tasks.java:189) at org.apache.iceberg.SnapshotProducer.commit(SnapshotProducer.java:367) at org.apache.iceberg.spark.source.SparkWrite.commitOperation(SparkWrite.java:215) at org.apache.iceberg.spark.source.SparkWrite.access$1300(SparkWrite.java:97) at org.apache.iceberg.spark.source.SparkWrite$BatchAppend.commit(SparkWrite.java:295) at org.apache.spark.sql.execution.datasources.v2.V2TableWriteExec.writeWithV2(WriteToDataSourceV2Exec.scala:372) ... 58 more Caused by: java.io.FileNotFoundException: No such file or directory: s3a://XXXXX/metadata/snap-6961165512118673576-2-a7c254f8-d3d8-415b-bf10-e9b1bdf8d241.avro at org.apache.hadoop.fs.s3a.S3AFileSystem.s3GetFileStatus(S3AFileSystem.java:3345) at org.apache.hadoop.fs.s3a.S3AFileSystem.innerGetFileStatus(S3AFileSystem.java:3174) at org.apache.hadoop.fs.s3a.S3AFileSystem.extractOrFetchSimpleFileStatus(S3AFileSystem.java:4915) at org.apache.hadoop.fs.s3a.S3AFileSystem.open(S3AFileSystem.java:1183) at org.apache.hadoop.fs.s3a.S3AFileSystem.open(S3AFileSystem.java:1161) at org.apache.hadoop.fs.FileSystem.open(FileSystem.java:957) at org.apache.iceberg.hadoop.HadoopInputFile.newStream(HadoopInputFile.java:183) ... 78 more
anyone found root cause for this?
Here is what was happening in my case.
- We have Defined below properties, so metadata can get cleanup regularly. write.metadata.delete-after-commit.enabled write.metadata.previous-versions-max
- If your multiple ingestion process running concurrently , these properties might contradict.
- i am retaining my metadata for bigger value so this issue will not happen. Below are my settings. write.metadata.delete-after-commit.enabled= false write.metadata.previous-versions-max=200
We had a similar issue here. IcebergFilesCommitter commits data files when a checkpoint completes, and stores the checkpoint ID in iceberg snapshot summary, and removes the committed manifest. When restoring from state, it tries to restore the max committed checkpoint id from table history. But this seems to be just best efforts because the snapshot might have been expired. And when that happens, IcebergFilesCommitter considers all files in the state as "uncommitted" and tris to commit them again, which can fail because the committed manifest has already been removed. @openinx is this a known limitation, so that we should be more careful with snapshot expiration?
@lirui-apache how about controling snapshot expiration with retain_last or older_than parameter? We can keep some snapshots and read max committed checkpoint id in this way.
@lirui-apache: For the record:
To restore the state of the Flink job, you need the previous snapshot (to identify the last committed snapshot), and the new data files and temporary manifest files (if the failure happened between snapshotState, and notifySnapshotCompltete).
So snapshot expiration and cleanup orphan files could also corrupt the state of the Flink job.
Hi @chenwyi2 @pvary , thanks for the clarifications. Yeah we changed our snapshot expire routine to keep the last snapshot created by Flink. If this is a limitation by design, I guess it's better to mention this in the doc.
@lirui-apache: Would you mind adding this to docs/flink-writes.md? I would be happy to review.
Thanks,
Peter
Sure, I'll open a PR for it
This issue has been automatically marked as stale because it has been open for 180 days with no activity. It will be closed in next 14 days if no further activity occurs. To permanently prevent this issue from being considered stale, add the label 'not-stale', but commenting on the issue is preferred when possible.
This issue has been closed because it has not received any activity in the last 14 days since being marked as 'stale'