Skip to content

[common] Fail on a short remote read instead of caching zero padding - #9593

Merged
JingsongLi merged 1 commit into
apache:masterfrom
jackylee-ch:cache-premature-eof
Sep 4, 2026
Merged

[common] Fail on a short remote read instead of caching zero padding#9593
JingsongLi merged 1 commit into
apache:masterfrom
jackylee-ch:cache-premature-eof

Conversation

@jackylee-ch

Copy link
Copy Markdown
Contributor

Purpose

CachingSeekableInputStream.readRemote fills a block with a private readFully that breaks out of its loop on EOF and returns the partially filled buffer, zero-padded. readBlock hands that buffer to cache.putBlock, so one short remote read becomes a durable wrong answer — persisted to disk under LocalDiskCacheManager — for every later read of the block.

The VectoredReadable branch two lines above already uses preadFully, which throws. Use IOUtils.readFully, already imported here, and drop the local copy.

Tests

CachingFileIOTest#testShortRemoteReadIsNotCachedAsZeroPaddedBlock.

Written with Claude Code; reasoning and verification are mine.

The block returned by readRemote is cached, so tolerating a short read
turned one truncated remote read into a durable zero-padded block. The
VectoredReadable branch in the same method already throws via
preadFully; use IOUtils.readFully for the other one.
@JingsongLi

Copy link
Copy Markdown
Contributor

+1

@JingsongLi
JingsongLi merged commit 4242ff2 into apache:master Sep 4, 2026
14 checks passed
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.

2 participants