Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Writing to S3 sometimes results in corrupted files #10710

Closed
sshkvar opened this issue Jan 20, 2022 · 10 comments · Fixed by #10729
Closed

Writing to S3 sometimes results in corrupted files #10710

sshkvar opened this issue Jan 20, 2022 · 10 comments · Fixed by #10729
Labels
bug Something isn't working correctness

Comments

@sshkvar
Copy link
Contributor

sshkvar commented Jan 20, 2022

Hi we have migrated to Trino 367 and faced issue with create table as select in iceberg (Potentially all connectors which uses TrinoS3FileSystem affected)

We are doing CTAS in iceberg from other table (~482013195 records).
After when we try to query created table

select count(uuid) from iceberg.schema.just_created_table

we got exception

Query 20220119_153450_24112_cjit2 failed: Error reading from s3a://.../94a0afda-26d1-497d-9d48-362c5b36e363.parquet at position 27214944

After some investigation we found that because of some reasons we have multiple versions of parquet files, this is strange because each parquet file has uuid in name and we just created this table.
you can find screenshot in this thread in slack

Additional retries of table creation shoved us that first version of parquet file always has the same size: 16 MB which is equal to s3MultipartMinFileSize.

After it we checked all changes in io.trino.plugin.hive.s3 package and found this one 7383734.
We have reverted this change and it helped. We didn't have corrupted parquets in iceberg tables anymore.

Important note: issue is accidental, sometimes table created without issue.

@hashhar
Copy link
Member

hashhar commented Jan 20, 2022

cc: @findepi @losipiuk @linzebing

@findepi
Copy link
Member

findepi commented Jan 20, 2022

Additional retries of table creation shoved us that first version of parquet file always has the same size: 16 MB which is equal to s3MultipartMinFileSize.

this is very suspicious

After it we checked all changes in io.trino.plugin.hive.s3 package and found this one 7383734.

Sounds like #9715 is related then
cc @joshthoward @electrum

We have reverted this change and it helped. We didn't have corrupted parquets in iceberg tables anymore.

good to hear that.

that also means you were testing with two builds, ie local modifications
did you also try with hive.s3.streaming.enabled off?

@findepi findepi changed the title TrinoS3FileSystem works incorrect in some cases Writing to S3 sometimes results in corrupted files Jan 20, 2022
@findepi findepi added bug Something isn't working correctness RELEASE-BLOCKER labels Jan 20, 2022
@losipiuk
Copy link
Member

If revert helps I vote for reverting as initial fix and then rework original improvement

@findepi
Copy link
Member

findepi commented Jan 21, 2022

No longer considered a release blocker, as #10716 merged.
thank you @linzebing @losipiuk

@findepi
Copy link
Member

findepi commented Jan 21, 2022

@sshkvar can you please confirm the current master no longer exhibits the problem?
@linzebing any chance this is testable? or there is nothing tbd in this issue?

@sbernauer
Copy link
Member

We had the same problem with corrupt parquet and ORC files. In our case the CTAS in iceberg failed with org.apache.iceberg.parquet.ParquetIO$ParquetInputFile@2700c43b is not a Parquet file. Expected magic number at tail, but found [49, -21, -31, 15]
The current master with reverted 7383734 fixed the issue for us 👍
Thanks @sshkvar for bringing this up!

@sshkvar
Copy link
Contributor Author

sshkvar commented Jan 21, 2022

@sshkvar can you please confirm the current master no longer exhibits the problem?

@findepi current master works without issue for us

@losipiuk
Copy link
Member

@sshkvar I reworked the commit which caused the problem and it should be fine now. The new PR is #10729. Would that be ok for you to test it out?

@sshkvar
Copy link
Contributor Author

sshkvar commented Jan 24, 2022

@sshkvar I reworked the commit which caused the problem and it should be fine now. The new PR is #10729. Would that be ok for you to test it out?

@losipiuk looks like reworked fix also working for us, I will continue testing and let you know in case of any issue

@losipiuk
Copy link
Member

@sshkvar I reworked the commit which caused the problem and it should be fine now. The new PR is #10729. Would that be ok for you to test it out?

@losipiuk looks like reworked fix also working for us, I will continue testing and let you know in case of any issue

Thanks @sshkvar. Very much appreciate your help here.

linzebing added a commit to linzebing/trino that referenced this issue Mar 24, 2022
Add a test testInsertIntoPartitionedTableLargeFiles to exercise multiple code paths of S3 streaming upload, with upload part size 5MB:
1. file size <= 5MB (shortcut to direct upload)
2. file size > 5MB but <= 10MB (which triggered trinodb#10710)
3. file size > 10MB
losipiuk pushed a commit that referenced this issue Mar 24, 2022
Add a test testInsertIntoPartitionedTableLargeFiles to exercise multiple code paths of S3 streaming upload, with upload part size 5MB:
1. file size <= 5MB (shortcut to direct upload)
2. file size > 5MB but <= 10MB (which triggered #10710)
3. file size > 10MB
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctness
Development

Successfully merging a pull request may close this issue.

5 participants