tikv / tikv/pd

client/resource_group: settle reported write consumption at response time

Open
#10,985 10 comments 0 reactions 0 assignees View on GitHub
contribution type/enhancement
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

Open the contributing 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.