Uh oh!
There was an error while loading. Please reload this page.
MINOR: Reader fails fast when footer size is larger than INT_MAX - #3136
Merged
Conversation
ConeyLiu
commented
Jan 24, 2025
ContributorAuthor
@dylanburati I have tried to support the footer with an unsigned int size in Java implementation. However, due to some limitations, it can not be done. We could write a footer(without encrypted) size larger than Int.MaxValue bytes, while we can not read it due to some limitations in thrift. java.io.IOException: cannotreadclassorg.apache.parquet.format.FileMetaData: MaxMessageSizereachedatorg.apache.parquet.format.Util.read(Util.java:393)
atorg.apache.parquet.format.Util.readFileMetaData(Util.java:156)
atorg.apache.parquet.format.converter.ParquetMetadataConverter$3.visit(ParquetMetadataConverter.java:1545)
atorg.apache.parquet.format.converter.ParquetMetadataConverter$3.visit(ParquetMetadataConverter.java:1542)
atorg.apache.parquet.format.converter.ParquetMetadataConverter$NoFilter.accept(ParquetMetadataConverter.java:1242)
atorg.apache.parquet.format.converter.ParquetMetadataConverter.readParquetMetadata(ParquetMetadataConverter.java:1542)
atorg.apache.parquet.hadoop.ParquetFileReader.readFooter(ParquetFileReader.java:637)
atorg.apache.parquet.hadoop.ParquetFileReader.readFooter(ParquetFileReader.java:571)
Causedby: org.apache.thrift.transport.TTransportException: MaxMessageSizereachedatorg.apache.thrift.transport.TEndpointTransport.checkReadBytesAvailable(TEndpointTransport.java:94)
atorg.apache.thrift.protocol.TCompactProtocol.checkStringReadLength(TCompactProtocol.java:726)
atorg.apache.thrift.protocol.TCompactProtocol.readString(TCompactProtocol.java:675)
atorg.apache.parquet.format.InterningProtocol.readString(InterningProtocol.java:269)
atorg.apache.parquet.format.KeyValue$KeyValueStandardScheme.read(KeyValue.java:415)
atorg.apache.parquet.format.KeyValue$KeyValueStandardScheme.read(KeyValue.java:392)
atorg.apache.parquet.format.KeyValue.read(KeyValue.java:327)
atorg.apache.parquet.format.FileMetaData$FileMetaDataStandardScheme.read(FileMetaData.java:1338)Since it is a rare condition. Here we just fail fast with an exception. cc @wgtmac |
ConeyLiu
commented
Jan 24, 2025
| LOG.debug("reading footer index at {}", fileMetadataLengthIndex); | ||
| f.seek(fileMetadataLengthIndex); | ||
| int fileMetadataLength = readIntLittleEndian(f); | ||
| long readFileMetadataLength = readIntLittleEndian(f) & 0xFFFFFFFFL; |
wgtmac
approved these changes
Mar 4, 2025
ConeyLiu
commented
Mar 5, 2025
ContributorAuthor
Thanks @wgtmac |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rationale for this change
The footer size is limited to unsigned int for some other language implementations, such as Rust. However, it is limited to Int.MaxValue on the Java side due to some limitations(eg, lack of unsigned int supports, the biggest byte array/buffer is limited to Int.MaxValue). So this PR reads the footer size as long and fails fast if it is larger than Int.MaxValue.
What changes are included in this PR?
Are these changes tested?
Existed UTs.
Are there any user-facing changes?
No