Partition batched KV gets by effective resource limiter
Summary
Storage::batch_get_command selects a resource limiter using the first request in a batch. A batch can contain requests with different request sources. The selected limiter controls read-pool admission and is also used to charge all returned values. Mixed-source batches can therefore apply the wrong limiter to some requests, including charging foreground response bytes to the background egress limiter or omitting background egress charges.
This first-request behavior predates the background egress limit in PR #19989 and affects other rate limiter types. Address the shared batching behavior for all applicable limiter types in a follow-up change.
Affected areas
- Batch assembly in
ReqBatcherfor normal-priority gets. - Limiter selection, read-pool admission, and response-byte charging in
src/storage/mod.rs(Storage::batch_get_command).
Proposed work
Partition batched gets by request source or effective limiter before calling Storage::batch_get_command. Ensure each resulting batch uses the appropriate limiter for both admission and charging. Check other limiter types that share this first-request selection behavior.
Acceptance criteria
- Requests with different effective limiters do not share one batch limiter.
- Background and foreground requests are admitted and charged under their respective limiter rules.
- A mixed-source batch test covers limiter selection, admission, and response-byte charging.
Related PR: https://github.com/tikv/tikv/pull/19989 Review comment: https://github.com/tikv/tikv/pull/19989#discussion_r4088102314 Requested by: @sanketkedia
Source: tikv/tikv