Skip to content

client/resource_group: gate paging metrics by IsCop signal#1

Merged
YuhaoZhang00 merged 1 commit into
feat/rc-paging-prechargefrom
dev/rc-paging-iscop
May 18, 2026
Merged

client/resource_group: gate paging metrics by IsCop signal#1
YuhaoZhang00 merged 1 commit into
feat/rc-paging-prechargefrom
dev/rc-paging-iscop

Conversation

@YuhaoZhang00
Copy link
Copy Markdown
Owner

Summary

Addresses @rleungx's review comment on tikv#10611 (and @JmPotato's earlier #3121995964): after `PredictedReadBytes` was promoted to a required `RequestInfo` method, the `paging_nonprecharge_*` branch could no longer tell a paging cold-start RPC from a regular non-cop read (CmdGet, CmdBatchGet, CmdScan, internal lookups). All reads with a zero hint were getting counted, inflating the metric by roughly the cluster's whole read-RPC volume and breaking the precharge-vs-nonprecharge comparison panel on the TiDB dashboard.

Adds `IsCop()` to the `RequestInfo` interface so the nonprecharge branch can scope itself to coprocessor reads. The hint-present branch is unchanged because `hint > 0` already implies a coprocessor caller; only the zero-hint branch needs the explicit cmd-type signal.

Changes

  • `controller/model.go`: add `IsCop() bool` to `RequestInfo` interface.
  • `controller/group_controller.go`: gate `observePagingNonprecharge` in `onResponseImpl` and `onResponseWaitImpl` on `req.IsCop()`.
  • `controller/testutil.go`: add `isCop` field and `IsCop()` method on `TestRequestInfo`.
  • `controller/group_controller_test.go`: add `TestPagingNonprechargeGatedByIsCop` asserting the counter only fires for cop reads.

Coordination

Companion changes:

Validation

  • `go test -tags enable_failpoints ./resource_group/controller/... -run 'TestPaging|TestNoPreCharge|TestOnResponseImpl|TestRequestAndResponse'` — all paging-related tests pass.
  • Two unrelated pre-existing failures (`TestControllerWithTwoGroupRequestConcurrency`, `TestGetResourceGroup`) reproduce on the base branch without this change.

After PredictedReadBytes was promoted to a required RequestInfo method,
the paging_nonprecharge_* branch fired for every non-write RPC reaching
the resource-control interceptor: point gets, batch gets, scans, and
internal lookups all looked identical to a paging coprocessor request
whose hint happened to be zero. The "paging cold-start" counter
inflated by roughly the full read-RPC volume of the cluster, breaking
the precharge-vs-nonprecharge comparison panel in the TiDB dashboard.

Expose IsCop() on the RequestInfo interface so the nonprecharge branch
can scope itself to coprocessor requests. The hint-present branch is
unchanged because hint>0 already implies a coprocessor caller; only the
zero-hint branch needs the explicit cmd-type signal, which client-go's
implementation will derive from tikvrpc.Request.Type.

Signed-off-by: Yuhao Zhang <yhzhang00@outlook.com>
@YuhaoZhang00 YuhaoZhang00 merged commit 4677b81 into feat/rc-paging-precharge May 18, 2026
1 of 3 checks passed
@YuhaoZhang00 YuhaoZhang00 deleted the dev/rc-paging-iscop branch May 18, 2026 11:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant