client/resource_group: settle reported write consumption at response time
- Dominant language
- Go
- Stars
- 1.2k
- Forks
- 783
- Avg merge
- 5d 21h
- Merged PRs (30d)
- 36
Description
## Problem
Write RU is knowable before a KV RPC, so `OnRequestWait` reserves the full write cost in the local limiter before sending the request. The same reservation is currently also added to cumulative reported consumption at request time, before the response is available. This couples local token reservation with settled consumption, places successful WRU in the request-side reporting interval, and lets an existing failed-write payback cross a periodic reporting boundary that only accepts positive monotonic deltas.
This timing problem was identified while reviewing #10611: https://github.com/tikv/pd/pull/10611#discussion_r3535135965
## Expected behavior
Keep the full request-time token reservation for admission control, but exclude the write reservation from reported consumption until the response settles. At response time, add the write reservation and the existing response delta together. Successful writes then report the full reservation at settlement, while any existing response-side payback is applied in the same reporting delta instead of trying to correct an earlier report.
## Scope
This issue covers controller-side reporting timing and settlement only. It does not change how `client-go` determines `ResponseInfo.Succeed()`, and it does not define settlement for requests that return no response.
## Version
Current master.
Contributor guide
Research direction
Start at the controller-side OnRequestWait path and trace how the write reservation enters cumulative reported consumption before the KV response. Then inspect response handling and client-go's ResponseInfo.Succeed() boundary. Done means request-time admission still reserves the full write cost, while response-time reporting settles that reservation with the response delta in one monotonic reporting update.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- backend, distributed-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100