fix(arrow-avro): fix split sync marker assembly and validate per-block sync markers - #10497
Open
ranflarion wants to merge 1 commit into
Open
fix(arrow-avro): fix split sync marker assembly and validate per-block sync markers#10497ranflarion wants to merge 1 commit into
ranflarion wants to merge 1 commit into
Conversation
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 free
to 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.
Which issue does this PR close?
Rationale for this change
Both
BlockDecoderandHeaderDecoderassemble the 16-byte sync marker with an offset derived from the size of the incoming fragment (sync[16 - to_decode..]), which only works when all 16 bytes arrive in onedecode()call; a marker straddling a chunk boundary gets scrambled (#10494). ForHeaderDecoderthis is live today: a header larger than one fetch whose trailing marker straddles the boundary yields a garbledHeader::sync(), the async reader's sync marker scan never matches, and a valid file silently reads as an empty stream.With assembly fixed,
Block.syncbecomes trustworthy, enabling the validation the Avro spec intends the marker for: both readers now compare each block's trailing marker against the file header's and reject a mismatch, matching the Java reference reader (DataFileStreamthrowsInvalid sync!) (#10495). This continues the recent hardening of the container decode path (#10237, #10407). Without it, a desynced or corrupted stream can decode silently into wrong values; avro-deflate block data is raw DEFLATE with no checksum, so this is a real silent-corruption window with transiently faulty object stores.What changes are included in this PR?
BlockDecoderandHeaderDecoderfill the sync marker from the front using the consumed count (offset = 16 - bytes_remaining).Readerand the async reader error withParseError("Avro block sync marker does not match file header")when a flushed block's marker differs from the header's.Are these changes tested?
BlockDecoderunit test feeds a block in every chunk size from 1 byte up and asserts the assembled marker; it fails on main.alltypes_plain.avro(the last block's sync marker) and asserts the read fails; on main the flip is accepted silently.Are there any user-facing changes?
Corrupt files that previously decoded silently (or, for the header case, silently produced an empty stream) now error, matching the Java reader. Appended files reuse the file's marker, so any file the reference reader accepts still reads fine.