You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "ranflarion (via GitHub)" <gi...@apache.org> on 2026/07/30 18:48:33 UTC
[PR] fix(arrow-avro): fix split sync marker assembly and validate per-block sync markers [arrow-rs]
ranflarion opened a new pull request, #10497:
URL: https://github.com/apache/arrow-rs/pull/10497
# Which issue does this PR close?
- Closes #10494.
- Closes #10495.
# Rationale for this change
Both `BlockDecoder` and `HeaderDecoder` assemble 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 one `decode()` call; a marker straddling a chunk boundary gets scrambled (#10494). For `HeaderDecoder` this is live today: a header larger than one fetch whose trailing marker straddles the boundary yields a garbled `Header::sync()`, the async reader's sync marker scan never matches, and a valid file silently reads as an empty stream.
With assembly fixed, `Block.sync` becomes 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 (`DataFileStream` throws `Invalid 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?
- `BlockDecoder` and `HeaderDecoder` fill the sync marker from the front using the consumed count (`offset = 16 - bytes_remaining`).
- The sync `Reader` and the async reader error with `ParseError("Avro block sync marker does not match file header")` when a flushed block's marker differs from the header's.
# Are these changes tested?
- A `BlockDecoder` unit test feeds a block in every chunk size from 1 byte up and asserts the assembled marker; it fails on main.
- Both readers get a test that flips the final byte of `alltypes_plain.avro` (the last block's sync marker) and asserts the read fails; on main the flip is accepted silently.
- Existing suites pass unchanged, including the roundtrip and range-read tests.
# 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.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(arrow-avro): fix split sync marker assembly and validate per-block sync markers [arrow-rs]
Posted by "Jefffrey (via GitHub)" <gi...@apache.org>.
Jefffrey merged PR #10497:
URL: https://github.com/apache/arrow-rs/pull/10497
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(arrow-avro): fix split sync marker assembly and validate per-block sync markers [arrow-rs]
Posted by "ranflarion (via GitHub)" <gi...@apache.org>.
ranflarion commented on PR #10497:
URL: https://github.com/apache/arrow-rs/pull/10497#issuecomment-5173845645
> thanks @ranflarion
thanks @Jefffrey
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(arrow-avro): fix split sync marker assembly and validate per-block sync markers [arrow-rs]
Posted by "Jefffrey (via GitHub)" <gi...@apache.org>.
Jefffrey commented on PR #10497:
URL: https://github.com/apache/arrow-rs/pull/10497#issuecomment-5172881375
thanks @ranflarion
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org