Repository navigation
fix(core): clamp chunk size of 0 to 1 for reader and writer - #8454
Open
Mola-maker wants to merge 1 commit into
Open
Mola-maker wants to merge 1 commit into
Mola-maker wants to merge 1 commit into
Conversation
A chunk size of 0 used to flow into the read and write paths unchanged: chunked reads produced 0-byte ranges and returned empty data, fetch planning never advanced its offset, and chunked writes never made progress. Clamp 0 to 1 at every OpReader/OpWriter construction site, matching the existing max(1) handling of OpReader::with_chunk and of concurrent requests, so a 0 chunk behaves like the smallest valid chunk instead of hanging or truncating data. Add regression tests covering chunk(0) for read, fetch and write.
This branch has not been deployed
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.
Fixes #8452.
Summary
chunk(0)on a reader or writer previously produced broken behavior: reads silently returned empty,fetchand writes hung forever. This was because the existingmax(1)guard inOpReader::with_chunkwas bypassed by the public builders, which copiedchunkintoOpReader/OpWriterunclamped (unlikeconcurrent, which was clamped in the same conversion), and the writer path had no guard at all.This PR clamps
chunkto a minimum of 1 at all four construction points incore/core/src/raw/ops.rs(bothFromconversions andOpWriter::with_chunk), sochunk(0)behaves likechunk(1). Non-zero inputs are unaffected. Clamping follows the existingmax(1)precedent forconcurrentin the same conversion; happy to switch to rejecting 0 if maintainers prefer.Tests
test_reader_read_with_chunk_zero,test_fetch_with_chunk_zero,test_writer_write_with_chunk_zero.cargo test -p opendal-core --lib: 239 passed, 0 failed (baseline 236 + 3 new).cargo clippy -p opendal-core --all-targets -- -D warnings: clean.cargo fmt --all -- --check: clean.AI Usage: Harness: Muse; Model: Muse Spark; Effort: investigation and tests.