bug(layers/throttle): throttle streaming ReadStream bytes instead of pre-charging ReadOptions::limit upper bounds on open()

Open
#9,567 0 comments 1 reaction 0 assignees View on GitHub

Maintainers usually reply within 1 day

@Xuanwo is already working on this.

Since Dec 4, 2026.

  • #9638 by @Xuanwo — open

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
rust

Research direction

Start with core/layers/throttle/src/lib.rs and trace how ThrottleWrapper::open charges bytes and how oio::ReadStream::read handles streaming reads. Read core/core/src/raw/oio/read/api.rs for the exact range read behavior, then check the CacheLayer pointer lookup path. Done means the acceptance criteria pass, including regression coverage for unbounded reads, limits above burst, large buffers, and cancellation.

Written by the indexing model from the issue text.

Description

bug core
Background

Re-evaluating #7453 in light of newly added ReadOptions::limit and CacheLayer:

  • In core/layers/throttle/src/lib.rs:137-154,266-296, ThrottleWrapper::open pre-charges range.size() upfront before streaming any bytes, while oio::ReadStream::read performs no bandwidth charging.
  • While #7453 had a valid production reason to rate-limit concurrent exact range reads (oio::Read::read, core/core/src/raw/oio/read/api.rs:38) before dispatching requests to prevent request/FD spikes, streaming open(range) allows short EOF and now carries defensive upper bounds via ReadOptions::limit:
    1. Unbounded reads (op.read("10gb"), range = 0..) bypass ThrottleLayer completely (range.size() == None).
    2. Defensive bounded reads (op.read_with("10_bytes").limit(10_MiB)) pre-charge the full 10 MiB upper bound and fail permanently with RateLimited (InsufficientCapacity) whenever limit > burst or limit > u32::MAX.
    3. CacheLayer's pointer lookup (65,664 bytes limit) fails on a throttled cache with burst = 32 KiB, degrading cache pointer lookups to misses.
Proposed Solution
  • Preserve pre-admission rate limiting where exact-length range reads require it, and define a clear policy for requests larger than burst (e.g., chunked waiting instead of immediate InsufficientCapacity where appropriate).
  • For streaming oio::Read::open / oio::ReadStream::read, do not charge the full ReadOptions::limit upper bound upfront; throttle actual bytes transferred through ReadStream::read (handling unbounded 0.. reads, single buffers > burst, and cancellation cleanly, while clearly distinguishing body delivery vs network admission).
Acceptance Criteria
  • Streaming open(0..) reads are throttled by ThrottleLayer rather than bypassing it.
  • Streaming reads with ReadOptions::limit > burst on small files succeed and are throttled according to actual bytes read (including CacheLayer pointer lookups over a 32 KiB-burst throttled cache).
  • Add regression tests covering unbounded 0.. reads, limit > burst, single buffer > burst, and cancellation.

This issue was reopened and independently verified by both audit leaders (gemini-4-neon and gpt-6.2-astra) ahead of Apache OpenDAL v0.60.0.

Dominant language
Rust
Stars
5.5k
Forks
869
Avg merge
8h 2m
Merged PRs (30d)
862

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from apache/opendal

All issues in apache/opendal

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.