Xuanwo opened a new pull request, #8989:
URL: https://github.com/apache/opendal/pull/8989

   # Which issue does this PR close?
   
   Related Issues: None.
   
   # Rationale for this change
   
   Fixes four core invariants in `opendal-core`:
   
   1. **`OpList::from_options` panic on oversized `start_after` without 
`glob`**: The 64 KiB `CompactValues` size check only executed when `glob` was 
`Some`, so passing a `start_after` longer than 65,531 bytes with `glob: None` 
panicked inside `CompactValues::encode` instead of returning 
`ErrorKind::ConfigInvalid`.
   2. **`WriteContext::calculate_chunk_size` infinite loop on zero 
`write_multi_max_size`**: Clamping an explicit writer chunk size against 
`Capability::write_multi_max_size == Some(0)` produced `(Some(0), true)`, 
causing `WriteState::write_chunk` to return `Ok(0)` forever in 
`WriteState::write_all` and `BufferSink::poll_flush`.
   3. **`ConcurrentTasks::clear` stale completion counter across reuse**: 
`clear()` dropped queued tasks and results without detaching 
`completed_but_unretrieved`, allowing previously completed or racing-to-cancel 
tasks to inflate `has_remaining()` and exceed the configured `concurrent` limit 
on subsequent reuse. `has_remaining()` also performed unchecked addition on 
`self.concurrent + completed.min(self.prefetch)`.
   4. **`raw::ThreeWays` missing `oio::Write::copy_from` delegation**: Unlike 
`raw::TwoWays`, `ThreeWays`'s `oio::Write` implementation omitted `copy_from`, 
falling back to the default `ErrorKind::Unsupported` implementation.
   
   # What changes are included in this PR?
   
   - `core/core/src/raw/ops.rs`: Always compute the `CompactValues` encoded 
length across both `start_after` and `glob` using saturating arithmetic before 
constructing `OpList` in `OpList::from_options`, and add boundary unit tests.
   - `core/core/src/types/context/write.rs`: Ignore zero values for 
`write_multi_min_size`, `write_multi_max_size`, and writer chunk options in 
`WriteContext::calculate_chunk_size`, and add unit tests covering zero bounds 
and end-to-end writes.
   - `core/core/src/raw/futures_util.rs`: Replace 
`self.completed_but_unretrieved` with a fresh `Arc::default()` in 
`ConcurrentTasks::clear()`, use `saturating_add` in `has_remaining()`, and add 
unit tests covering counter reset/detachment and saturation.
   - `core/core/src/raw/enum_utils.rs`: Forward `oio::Write::copy_from` across 
all three variants of `ThreeWays`, and add a unit test covering all variants.
   
   # Are there any user-facing changes?
   
   - `OpList::from_options` (and `Operator::list_with().start_after(...)`) now 
returns `ErrorKind::ConfigInvalid` instead of panicking when `start_after` 
exceeds the 64 KiB compact encoding limit.
   - Writing with an explicit `.chunk(...)` when `write_multi_max_size` is 
`Some(0)` now completes instead of looping indefinitely.
   - `raw::ConcurrentTasks::clear` now resets and detaches its completion 
counter so reused queues honor their `concurrent` bound.
   - `raw::ThreeWays` now delegates `oio::Write::copy_from` to the active 
variant.
   
   # Breaking changes
   
   # AI Usage Statement
   
   - Harness: pi
   - Model: Gemini 4 Neon
   - Effort: high
   - Role: Verified all four invariants against `opendal-core`, implemented the 
fixes and deterministic unit tests, and ran unit tests, clippy, formatting, and 
typo checks.
   


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to