Skip to content

Fix EC striped reads: correct slice offsets in stripe buffer and drain futures#76

Draft
lgbo-ustc wants to merge 1 commit intoClickHouse:masterfrom
bigo-sg:ec_stripe_read_fix
Draft

Fix EC striped reads: correct slice offsets in stripe buffer and drain futures#76
lgbo-ustc wants to merge 1 commit intoClickHouse:masterfrom
bigo-sg:ec_stripe_read_fix

Conversation

@lgbo-ustc
Copy link
Copy Markdown

problem



2026-04-21 11:09:11.627609, p20876, th140122365355776, DEBUG1 block[6] id=-9223372000575385370, size=24117248, locs=127.0.0.1 , poolid=BP-1606066499-127.0.0.1 -1606188026755

2026-04-21 11:09:11.627622, p20876, th140122365355776, DEBUG1 block[7] id=-9223372000575385369, size=24117248, locs=127.0.0.1 , poolid=BP-1606066499-127.0.0.1 -1606188026755

2026-04-21 11:09:11.627634, p20876, th140122365355776, DEBUG1 block[8] id=-9223372000575385368, size=24117248, locs=127.0.0.1 , poolid=BP-1606066499-127.0.0.1 -1606188026755

2026-04-21 11:09:11.631057, p20876, th140122364303104, DEBUG1 PeerCache miss for datanode xxxx (127.0.0.1) uuid(625e6588-74f6-4586-946b-c41cda66984f).
2026-04-21 11:09:11.631369, p20876, th140122365355776, DEBUG1 PeerCache miss for datanode xxxx (127.0.0.1 ) uuid(c876e854-1f31-4d70-8342-4409e414224b).
2026-04-21 11:09:11.998 <Information> jni: Cancel LocalExecutor 140123096901248
2026-04-21 11:09:11.998 <Information> jni: Cancel LocalExecutor 140122298507264
26/04/21 11:09:11.999 ERROR [Executor task launch worker for task 16.0 in stage 1.0 (TID 92)] TaskResources: Task 92 failed by error: 
org.apache.gluten.exception.GlutenException: Invalid: Parquet magic bytes not found in footer. Either the file is corrupted or this is not a parquet file.
0. parquet::ParquetInvalidOrCorruptedFileException::ParquetInvalidOrCorruptedFileException<char const*, 0>(char const*) @ 0x0000000017e18d17

modification

divideOneStripe: add bufBaseOffset and include it when computing addSlice() positions into the destination ByteBuffer.

Reason: readOneStripe() may read a sub-range of one logical stripe; valid bytes lie in curStripeBuf at [stripeBufOffset, stripeLimit) where stripeBufOffset is offsetInBlockGroup % stripeLen. Previously slices were laid out from buffer offset 0, while copyToTarget() consumed from stripeBufOffset, so applications read wrong bytes (zeros or stale data). That broke format parsers that depend on exact byte streams (e.g. Parquet footer magic).

StripedInputStreamImpl: pass stripeBufOffset into divideOneStripe() for sequential reads; pass 0 in fetchBlockByteRange() where the buffer holds exactly the requested byte range.

resetCurStripeBuffer: after clear(), memset the full capacity of curStripeBuf and parityBuf when allocated so EC logical holes (ALLZERO / tail padding) do not leak bytes from a prior stripe.

StripingCell: fix constructor and init() parameter shadowing (ecPolicy and idxInBlkGroup were self-assigned and never stored in members).

StripeReader::readStripe: remove the early break that cleared futures once fetchedChunksNum reached dataBlkNum. Parity chunk reads and decode retry paths enqueue additional futures and must all complete before leaving the loop.

…n futures

divideOneStripe: add bufBaseOffset and include it when computing addSlice()
positions into the destination ByteBuffer.

Reason: readOneStripe() may read a sub-range of one logical stripe; valid bytes
lie in curStripeBuf at [stripeBufOffset, stripeLimit) where stripeBufOffset is
offsetInBlockGroup % stripeLen. Previously slices were laid out from buffer
offset 0, while copyToTarget() consumed from stripeBufOffset, so applications
read wrong bytes (zeros or stale data). That broke format parsers that depend on
exact byte streams (e.g. Parquet footer magic).

StripedInputStreamImpl: pass stripeBufOffset into divideOneStripe() for
sequential reads; pass 0 in fetchBlockByteRange() where the buffer holds exactly
the requested byte range.

resetCurStripeBuffer: after clear(), memset the full capacity of curStripeBuf
and parityBuf when allocated so EC logical holes (ALLZERO / tail padding) do
not leak bytes from a prior stripe.

StripingCell: fix constructor and init() parameter shadowing (ecPolicy and
idxInBlkGroup were self-assigned and never stored in members).

StripeReader::readStripe: remove the early break that cleared futures once
fetchedChunksNum reached dataBlkNum. Parity chunk reads and decode retry paths
enqueue additional futures and must all complete before leaving the loop.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant