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

   # Which issue does this PR close?
   
   Related Issues: None.
   
   # Rationale for this change
   
   This PR fixes four correctness bugs across `opendal-layer-timeout`, 
`opendal-layer-tail-cut`, and `opendal-layer-logging`:
   
   1. **Stacked `TimeoutLayer` executor deadlines (`core/layers/timeout`)**: 
`TimeoutExecutor::timeout` previously ignored `self.exec.timeout()`, and 
`TimeoutService::io_context` only wrapped the context when `operation_timeouts` 
had an override. As a result, stacking an inner `TimeoutLayer` (for example, 
before `RetryLayer`) and an outer `TimeoutLayer` let the outer layer's 
`apply_context` overwrite the inner layer's shorter `io_timeout` for concurrent 
multipart/block/position tasks, while an inner `with_operation_timeout` 
override could also clobber a shorter outer `io_timeout`.
   2. **Mixed read histograms in `TailCutLayer` (`core/layers/tail-cut`)**: 
`TailCutWrapper<oio::Read>::open` (TTFB), 
`TailCutWrapper<oio::ReadStream>::read` (per-chunk latency tagged with the full 
stream `range.size()`), and `TailCutWrapper<oio::Read>::read` (full-range 
transfer) all shared the same `(Operation::Read, range.size())` histogram. 
Streaming a large object flooded the large-range bucket with fast per-chunk 
latencies, driving deadlines down to `min_deadline` and cancelling healthy 
full-range reads and opens.
   3. **Unbucketed writes in `TailCutLayer` (`core/layers/tail-cut`)**: 
`TailCutWrapper<oio::Write>` always passed `None` (`[256MB, ∞)`) for `write` 
and `copy_from` instead of bucketing by `bs.len()` and `range.size()`, leaving 
the smaller write size buckets unused and allowing fast small writes to 
collapse deadlines for large writes and `copy_from` calls.
   4. **Unbounded range panic in `LoggingWriter::copy_from` 
(`core/layers/logging`)**: `LoggingWriter::copy_from` called 
`range.size().expect(...)`, panicking inside the logging layer on an unbounded 
`BytesRange` instead of delegating to the inner writer.
   
   # What changes are included in this PR?
   
   - `core/layers/timeout/src/lib.rs`:
     - Assign a per-layer identifier to `TimeoutLayer` so each layer's 
operation-level executor wrapper supersedes its own `apply_context` default 
(preserving per-operation overrides longer than `io_timeout`) without 
discarding deadlines from other stacked `TimeoutLayer`s or base executors.
     - Race each `TimeoutExecutor` deadline against `self.exec.timeout()` so 
stacked layers and direct `context().executor().timeout()` callers enforce the 
tightest deadline.
     - Always apply the resolved I/O timeout in `TimeoutService::io_context`.
     - Add paused-time unit tests covering stacked `TimeoutLayer` combinations 
(shorter inner `io_timeout`, shorter outer `io_timeout` vs inner override, 
longer inner `Write` override under outer `io_timeout`, and direct context 
executor stacking).
   - `core/layers/tail-cut/src/lib.rs`:
     - Introduce dedicated `StatKey::ReadOpen` and `StatKey::ReadStream` 
histogram slots in `TailCutStats` while preserving `Operation::Read` on 
tail-cut timeout errors and full-range `Read::read` size bucketing.
     - Bucket `TailCutWrapper<oio::Write>::write` by `Some(bs.len() as u64)` 
and `copy_from` by `range.size()`, and remove the unused wrapper-level `size` 
field.
     - Add unit tests verifying read open/stream/range histogram isolation and 
write/`copy_from` size bucketing.
   - `core/layers/logging/src/lib.rs` & `core/layers/logging/src/tests.rs`:
     - Replace `range.size().expect(...)` with 
`range.size().unwrap_or_default()` in `LoggingWriter::copy_from`.
     - Add a unit test verifying unbounded `copy_from` ranges forward to the 
inner writer and log errors without panicking.
   
   # Are there any user-facing changes?
   
   - Stacked `TimeoutLayer`s now enforce the tighter concurrent task deadline 
across layers while preserving per-operation overrides.
   - `TailCutLayer` no longer mixes streaming chunk latencies into full-range 
read or open baselines, and buckets `write` / `copy_from` deadlines by 
payload/range size.
   - `LoggingLayer` no longer panics when `oio::Write::copy_from` is called 
with an unbounded `BytesRange`.
   
   # Breaking changes
   
   # AI Usage Statement
   
   - Harness: pi
   - Model: Gemini 4 Neon
   - Effort: high
   - Role: Verified each issue against the codebase, implemented the fixes and 
unit tests across `opendal-layer-timeout`, `opendal-layer-tail-cut`, and 
`opendal-layer-logging`, and ran unit tests, clippy, and formatting 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