iceberg icon indicating copy to clipboard operation
iceberg copied to clipboard

Flink write iceberg bug(org.apache.iceberg.exceptions.NotFoundException)

Open 95liu opened this issue 4 years ago • 17 comments

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

95liu avatar Sep 24 '22 04:09 95liu

Could you please share the full Exception, and the Flink version what is used in your case? Thanks, Peter

pvary avatar Sep 26 '22 05:09 pvary

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 avatar Oct 08 '22 01:10 95liu

@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?

pvary avatar Oct 08 '22 05:10 pvary

We meet this issue in these two situations:

  • No access permission
  • write metadata into wrong HDFS location

xxubai avatar Oct 09 '22 06:10 xxubai

Any failover happen? There's antother file not found exception reported in #6066

luoyuxia avatar Oct 31 '22 07:10 luoyuxia

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.

elisabetao avatar Mar 16 '23 16:03 elisabetao

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

chennurchaitanya avatar May 17 '23 15:05 chennurchaitanya

anyone found root cause for this?

venketeshdream11 avatar May 22 '23 12:05 venketeshdream11

Here is what was happening in my case.

  1. We have Defined below properties, so metadata can get cleanup regularly. write.metadata.delete-after-commit.enabled write.metadata.previous-versions-max
  2. If your multiple ingestion process running concurrently , these properties might contradict.
  3. 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

chennurchaitanya avatar May 22 '23 16:05 chennurchaitanya

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 avatar Jul 26 '23 09:07 lirui-apache

@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.

chenwyi2 avatar Oct 30 '23 02:10 chenwyi2

@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.

pvary avatar Nov 06 '23 06:11 pvary

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 avatar Nov 06 '23 09:11 lirui-apache

@lirui-apache: Would you mind adding this to docs/flink-writes.md? I would be happy to review. Thanks, Peter

pvary avatar Nov 06 '23 12:11 pvary

Sure, I'll open a PR for it

lirui-apache avatar Nov 07 '23 04:11 lirui-apache

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.

github-actions[bot] avatar Aug 20 '24 00:08 github-actions[bot]

This issue has been closed because it has not received any activity in the last 14 days since being marked as 'stale'

github-actions[bot] avatar Sep 11 '24 00:09 github-actions[bot]