HoodieNativeAvroHFileReader throws ZipException on valid column_stats HFiles during MDT compaction
Bug description
After upgrading from Hudi 0.14.x to 1.0.2, the default HoodieNativeAvroHFileReader (enabled via hoodie.metadata.reader.use.native.reader=true, which is the 1.0.2 default) throws a java.util.zip.ZipException when reading certain column_stats partition HFiles in the metadata table (MDT) during compaction. The same HFiles read successfully when using the legacy HoodieAvroHFileReader (hoodie.metadata.reader.use.native.reader=false).
The failure occurs deterministically on specific HFiles — not all column_stats HFiles trigger it. The affected HFiles are byte-valid (not corrupted on storage) and were written by Hudi 1.0.2 writers with no errors at write time. The crash surfaces during the next MDT compaction that reads the affected HFile block.
Impact
The ZipException crash-loops the writer process on every subsequent write attempt, because each write triggers MDT compaction which re-reads the same corrupted block. This makes the affected table unwritable until the workaround is applied.
Steps to reproduce
- Use Hudi 1.0.2 with
column_statsmetadata partition enabled (default). - Write to a COW table with multiple concurrent writers using OCC (DynamoDB-based lock provider) over an extended period.
- At some point, an MDT compaction reads a
column_statsHFile block that triggers theZipException.
Note: The issue is intermittent — it depends on the specific data/block layout written to the HFile. Not every column_stats HFile triggers it.
Expected behavior
HoodieNativeAvroHFileReader should read all HFiles that HoodieAvroHFileReader can read without error. Both readers operate on the same byte-identical files.
Actual behavior
java.util.zip.ZipException: <decompression error>
at java.base/java.util.zip.Inflater.inflateBytesBytes(Native Method)
at java.base/java.util.zip.Inflater.inflate(Inflater.java:378)
at org.apache.hadoop.hbase.io.compress.HFileDecompressor.decompress(...)
at org.apache.hadoop.hbase.io.hfile.HFileBlock.unpack(...)
at org.apache.hudi.io.storage.HoodieNativeAvroHFileReader.readBlock(...)
...
The legacy HoodieAvroHFileReader reads the same file cleanly.
Diagnosis
A/B testing confirmed the issue is isolated to the reader implementation:
hoodie.metadata.reader.use.native.reader=true(native, 1.0.2 default):ZipExceptionon the affected HFile blockhoodie.metadata.reader.use.native.reader=false(legacy): reads all records successfully (confirmed >9M records read without error from the same file)
The native reader's block decompression logic in HoodieNativeAvroHFileReader mis-handles certain HFile block encodings that the HBase-backed legacy reader handles correctly. The root cause appears to be in the native reader's block unpacking/decompression path, not in the data written to the HFile.
Workaround
Set hoodie.metadata.reader.use.native.reader=false in the writer configuration to fall back to the legacy HoodieAvroHFileReader. This avoids the crash with no functional difference (same data, same MDT behavior).
Environment
- Hudi version: 1.0.2
- Spark version: 3.5.x
- Java version: JDK 17
- Storage: S3
- Table type: COW
- MDT partitions enabled:
files,column_stats - Lock provider: DynamoDB-based OCC
Full exception stack trace
HoodieException: Failed to instantiate Metadata table
Caused by: HoodieCompactionException: Could not compact <table>/.hoodie/metadata
Caused by: HoodieIOException: unable to read next record from hfile
at org.apache.hudi.io.storage.HoodieNativeAvroHFileReader$RecordIterator.hasNext(HoodieNativeAvroHFileReader.java:353)
Caused by: java.util.zip.ZipException: invalid block type
at org.apache.hudi.io.storage.HoodieAirliftGzipDecompressor.decompress(...)
at org.apache.hadoop.hbase.io.hfile.HFileBlock.unpack(HFileBlock.java:199)
The exact ZipException message is invalid block type (not "Not in GZIP format") — this points to the native reader's HoodieAirliftGzipDecompressor failing to decompress a block that the HBase-backed reader handles fine.
Culprit file details
- MDT partition:
column_stats/ - Culprit HFile:
col-stats-0000-0_0-383-1122919_<instant>.hfile(acolumn_statspartition base file) - HFile compression codec: Default (GZIP) — the file was written by Hudi 1.0.2 writers with no write-time errors
- HFile integrity: Byte-valid on storage (verified via checksums); not a storage corruption issue
A/B result on the exact culprit file
_hoodie.hfile.use.native.reader |
Reader class | Result |
|---|---|---|
false |
HoodieHBaseAvroHFileReader |
✅ SUCCESS — 9,115,795 records read clean |
true |
HoodieNativeAvroHFileReader |
❌ FAILURE — unable to read next record from hfile → java.util.zip.ZipException: invalid block type |
Same bytes, same Avro schema (12 fields). The HBase reader fully iterates the file; the native reader throws on the same block. This confirms the bug is in the native reader's decompression path (HoodieAirliftGzipDecompressor), not in the data.
Crash context
The failure occurs during MDT compaction (a distributed Spark collect on the column_stats partition). It crash-loops the writer because every write attempt triggers MDT compaction, which re-reads the same block and throws.
Workaround confirmed
hoodie.metadata.reader.use.native.reader=false in the writer config avoids the crash with no functional regression.
cc @linliu-code for taking a look~