Skip to content

Commit f3bf62b

Browse files
committed
*: unify RUv2 collection via RUDetails
Signed-off-by: disksing <i@disksing.com>
1 parent cb1e1e6 commit f3bf62b

35 files changed

+318
-552
lines changed

DEPS.bzl

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6530,13 +6530,13 @@ def go_deps():
65306530
name = "com_github_pingcap_kvproto",
65316531
build_file_proto_mode = "disable_global",
65326532
importpath = "github.com/pingcap/kvproto",
6533-
sha256 = "a16a464c372f295061deaf6134a9e26602ebf780beb9d7d3324fb8d1e333eace",
6534-
strip_prefix = "github.com/pingcap/kvproto@v0.0.0-20260326084500-678ff92b1edd",
6533+
sha256 = "c2077f1a08a47110acb8bde930d160de9bbda18def567168aff642ede33a1255",
6534+
strip_prefix = "github.com/pingcap/kvproto@v0.0.0-20260331120830-0d407c8b3f6e",
65356535
urls = [
6536-
"http://bazel-cache.pingcap.net:8080/gomod/github.com/pingcap/kvproto/com_github_pingcap_kvproto-v0.0.0-20260326084500-678ff92b1edd.zip",
6537-
"http://ats.apps.svc/gomod/github.com/pingcap/kvproto/com_github_pingcap_kvproto-v0.0.0-20260326084500-678ff92b1edd.zip",
6538-
"https://cache.hawkingrei.com/gomod/github.com/pingcap/kvproto/com_github_pingcap_kvproto-v0.0.0-20260326084500-678ff92b1edd.zip",
6539-
"https://storage.googleapis.com/pingcapmirror/gomod/github.com/pingcap/kvproto/com_github_pingcap_kvproto-v0.0.0-20260326084500-678ff92b1edd.zip",
6536+
"http://bazel-cache.pingcap.net:8080/gomod/github.com/pingcap/kvproto/com_github_pingcap_kvproto-v0.0.0-20260331120830-0d407c8b3f6e.zip",
6537+
"http://ats.apps.svc/gomod/github.com/pingcap/kvproto/com_github_pingcap_kvproto-v0.0.0-20260331120830-0d407c8b3f6e.zip",
6538+
"https://cache.hawkingrei.com/gomod/github.com/pingcap/kvproto/com_github_pingcap_kvproto-v0.0.0-20260331120830-0d407c8b3f6e.zip",
6539+
"https://storage.googleapis.com/pingcapmirror/gomod/github.com/pingcap/kvproto/com_github_pingcap_kvproto-v0.0.0-20260331120830-0d407c8b3f6e.zip",
65406540
],
65416541
)
65426542
go_repository(
@@ -7805,13 +7805,13 @@ def go_deps():
78057805
build_tags = ["nextgen", "intest"],
78067806
build_file_proto_mode = "disable_global",
78077807
importpath = "github.com/tikv/client-go/v2",
7808-
sha256 = "46ee8c64e0f95ad1514e824506e49ea1d9f75329ee6419aae4b0817336550557",
7809-
strip_prefix = "github.com/tikv/client-go/v2@v2.0.8-0.20260401083018-b7f9a9e9d2ab",
7808+
sha256 = "c5351be1d123dd8878b3fcf0a2f3ec1a72f6074b031a40740f624595095fba48",
7809+
strip_prefix = "github.com/tikv/client-go/v2@v2.0.8-0.20260410090020-3558d1d63481",
78107810
urls = [
7811-
"http://bazel-cache.pingcap.net:8080/gomod/github.com/tikv/client-go/v2/com_github_tikv_client_go_v2-v2.0.8-0.20260401083018-b7f9a9e9d2ab.zip",
7812-
"http://ats.apps.svc/gomod/github.com/tikv/client-go/v2/com_github_tikv_client_go_v2-v2.0.8-0.20260401083018-b7f9a9e9d2ab.zip",
7813-
"https://cache.hawkingrei.com/gomod/github.com/tikv/client-go/v2/com_github_tikv_client_go_v2-v2.0.8-0.20260401083018-b7f9a9e9d2ab.zip",
7814-
"https://storage.googleapis.com/pingcapmirror/gomod/github.com/tikv/client-go/v2/com_github_tikv_client_go_v2-v2.0.8-0.20260401083018-b7f9a9e9d2ab.zip",
7811+
"http://bazel-cache.pingcap.net:8080/gomod/github.com/tikv/client-go/v2/com_github_tikv_client_go_v2-v2.0.8-0.20260410090020-3558d1d63481.zip",
7812+
"http://ats.apps.svc/gomod/github.com/tikv/client-go/v2/com_github_tikv_client_go_v2-v2.0.8-0.20260410090020-3558d1d63481.zip",
7813+
"https://cache.hawkingrei.com/gomod/github.com/tikv/client-go/v2/com_github_tikv_client_go_v2-v2.0.8-0.20260410090020-3558d1d63481.zip",
7814+
"https://storage.googleapis.com/pingcapmirror/gomod/github.com/tikv/client-go/v2/com_github_tikv_client_go_v2-v2.0.8-0.20260410090020-3558d1d63481.zip",
78157815
],
78167816
)
78177817
go_repository(

go.mod

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ require (
101101
github.com/pingcap/errors v0.11.5-0.20260310054046-9c8b3586e4b2
102102
github.com/pingcap/failpoint v0.0.0-20240528011301-b51a646c7c86
103103
github.com/pingcap/fn v1.0.0
104-
github.com/pingcap/kvproto v0.0.0-20260326084500-678ff92b1edd
104+
github.com/pingcap/kvproto v0.0.0-20260331120830-0d407c8b3f6e
105105
github.com/pingcap/log v1.1.1-0.20250917021125-19901e015dc9
106106
github.com/pingcap/metering_sdk v0.0.0-20260324055927-14fead745f1d
107107
github.com/pingcap/sysutil v1.0.1-0.20240311050922-ae81ee01f3a5
@@ -124,7 +124,7 @@ require (
124124
github.com/stathat/consistent v1.0.0
125125
github.com/stretchr/testify v1.11.1
126126
github.com/tiancaiamao/appdash v0.0.0-20181126055449-889f96f722a2
127-
github.com/tikv/client-go/v2 v2.0.8-0.20260401083018-b7f9a9e9d2ab
127+
github.com/tikv/client-go/v2 v2.0.8-0.20260410090020-3558d1d63481
128128
github.com/tikv/pd/client v0.0.0-20260404141330-8a6813497b52
129129
github.com/timakin/bodyclose v0.0.0-20241222091800-1db5c5ca4d67
130130
github.com/twmb/murmur3 v1.1.6
@@ -353,7 +353,7 @@ require (
353353
google.golang.org/genproto/googleapis/rpc v0.0.0-20250707201910-8d1bb00bc6a7 // indirect
354354
google.golang.org/protobuf v1.36.10
355355
gopkg.in/inf.v0 v0.9.1 // indirect
356-
gopkg.in/natefinch/lumberjack.v2 v2.2.1
356+
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
357357
gopkg.in/yaml.v3 v3.0.1 // indirect
358358
k8s.io/apimachinery v0.29.11 // indirect
359359
k8s.io/klog/v2 v2.120.1 // indirect

go.sum

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -728,8 +728,8 @@ github.com/pingcap/fn v1.0.0/go.mod h1:u9WZ1ZiOD1RpNhcI42RucFh/lBuzTu6rw88a+oF2Z
728728
github.com/pingcap/goleveldb v0.0.0-20191226122134-f82aafb29989 h1:surzm05a8C9dN8dIUmo4Be2+pMRb6f55i+UIYrluu2E=
729729
github.com/pingcap/goleveldb v0.0.0-20191226122134-f82aafb29989/go.mod h1:O17XtbryoCJhkKGbT62+L2OlrniwqiGLSqrmdHCMzZw=
730730
github.com/pingcap/kvproto v0.0.0-20191211054548-3c6b38ea5107/go.mod h1:WWLmULLO7l8IOcQG+t+ItJ3fEcrL5FxF0Wu+HrMy26w=
731-
github.com/pingcap/kvproto v0.0.0-20260326084500-678ff92b1edd h1:FA2DzGly3tuBWFjktkJxmqeOVEqgrsUvKMQXAw9xvWE=
732-
github.com/pingcap/kvproto v0.0.0-20260326084500-678ff92b1edd/go.mod h1:z6+aAHB7dBkA+LyinEX+48/ImRJ3jag0Hg0c7wkhEvE=
731+
github.com/pingcap/kvproto v0.0.0-20260331120830-0d407c8b3f6e h1:KzYXzOwFIg7iLAPwTZUxKwRSS+4lFGewvjuxE2ZA4sU=
732+
github.com/pingcap/kvproto v0.0.0-20260331120830-0d407c8b3f6e/go.mod h1:z6+aAHB7dBkA+LyinEX+48/ImRJ3jag0Hg0c7wkhEvE=
733733
github.com/pingcap/log v0.0.0-20210625125904-98ed8e2eb1c7/go.mod h1:8AanEdAHATuRurdGxZXBz0At+9avep+ub7U1AGYLIMM=
734734
github.com/pingcap/log v1.1.0/go.mod h1:DWQW5jICDR7UJh4HtxXSM20Churx4CQL0fwL/SoOSA4=
735735
github.com/pingcap/log v1.1.1-0.20250917021125-19901e015dc9 h1:qG9BSvlWFEE5otQGamuWedx9LRm0nrHvsQRQiW8SxEs=
@@ -895,8 +895,12 @@ github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4=
895895
github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
896896
github.com/tidwall/sjson v1.2.5 h1:kLy8mja+1c9jlljvWTlSazM7cKDRfJuR/bOJhcY5NcY=
897897
github.com/tidwall/sjson v1.2.5/go.mod h1:Fvgq9kS/6ociJEDnK0Fk1cpYF4FIW6ZF7LAe+6jwd28=
898-
github.com/tikv/client-go/v2 v2.0.8-0.20260401083018-b7f9a9e9d2ab h1:t9Kh7tVsSSUMuSPpHChPF6W3VtN4Kq7Gi8EgWPbYRyY=
899-
github.com/tikv/client-go/v2 v2.0.8-0.20260401083018-b7f9a9e9d2ab/go.mod h1:lfRxHwyBp1rjTmNC04SUZ+dqk7i1R1AeJ2zraMQaNvY=
898+
github.com/tikv/client-go/v2 v2.0.8-0.20260409052733-d1ffcbb90bf4 h1:W8hr6o/rDOUAiOUmUu/LZ1X/jx8HuN5wD23eW3T3Odo=
899+
github.com/tikv/client-go/v2 v2.0.8-0.20260409052733-d1ffcbb90bf4/go.mod h1:PILS4Yr8mWPD7J6W0+hVq4Z+lwhTIYxPYUA/OTxPSvg=
900+
github.com/tikv/client-go/v2 v2.0.8-0.20260410083358-f43b3acd921a h1:yWAbkb3PMKTWCU/pC2CrnMp7PtcBU8q00cvOYNsfmaM=
901+
github.com/tikv/client-go/v2 v2.0.8-0.20260410083358-f43b3acd921a/go.mod h1:PILS4Yr8mWPD7J6W0+hVq4Z+lwhTIYxPYUA/OTxPSvg=
902+
github.com/tikv/client-go/v2 v2.0.8-0.20260410090020-3558d1d63481 h1:D+hkz2TObmZ9Hgh1Ww3VHCv1+SeK0XaALBUpviGlNtM=
903+
github.com/tikv/client-go/v2 v2.0.8-0.20260410090020-3558d1d63481/go.mod h1:PILS4Yr8mWPD7J6W0+hVq4Z+lwhTIYxPYUA/OTxPSvg=
900904
github.com/tikv/pd/client v0.0.0-20260404141330-8a6813497b52 h1:fXIMowblD3qdfHXJYGJpe7SbBlTO4S9GPVZZvL3CPG8=
901905
github.com/tikv/pd/client v0.0.0-20260404141330-8a6813497b52/go.mod h1:I2yRx/Yf8Y8kgM5f3VNp4a8fWpnjPC4TxWk554AY8bM=
902906
github.com/timakin/bodyclose v0.0.0-20241222091800-1db5c5ca4d67 h1:9LPGD+jzxMlnk5r6+hJnar67cgpDIz/iyD+rfl5r2Vk=

pkg/ddl/backfilling_operators.go

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -532,16 +532,6 @@ func (w *tableScanWorker) scanRecords(task TableScanTask, sender func(IndexRecor
532532
idxResults []IndexRecordChunk
533533
execDetails kvutil.ExecDetails
534534
)
535-
// Local ingest may trigger partial import/reset while the scan transaction is
536-
// still open, so only the global-sort path can stream results immediately.
537-
enableStreaming := w.reorgMeta.UseCloudStorage
538-
sendResult := func(idxResult IndexRecordChunk) {
539-
sender(idxResult)
540-
if w.cpOp != nil {
541-
w.cpOp.UpdateChunk(task.ID, int(idxResult.tableScanRowCount), idxResult.Done)
542-
}
543-
w.totalCount.Add(idxResult.tableScanRowCount)
544-
}
545535
var scanCtx context.Context = w.ctx
546536
if scanCtx.Value(kvutil.ExecDetailsKey) == nil {
547537
scanCtx = context.WithValue(w.ctx, kvutil.ExecDetailsKey, &execDetails)
@@ -575,11 +565,6 @@ func (w *tableScanWorker) scanRecords(task TableScanTask, sender func(IndexRecor
575565
failpoint.InjectCall("beforeGetChunk")
576566
srcChk := w.getChunk()
577567
done, err = fetchTableScanResult(scanCtx, w.copCtx.GetBase(), rs, srcChk)
578-
failpoint.Inject("mockScanRecordPartialError", func(val failpoint.Value) {
579-
if shouldFail, _ := val.(bool); shouldFail {
580-
err = errors.New("mock partial scan error")
581-
}
582-
})
583568
if err != nil || scanCtx.Err() != nil {
584569
w.recycleChunk(srcChk)
585570
terror.Call(rs.Close)
@@ -589,21 +574,19 @@ func (w *tableScanWorker) scanRecords(task TableScanTask, sender func(IndexRecor
589574
execDetails = kvutil.ExecDetails{}
590575

591576
_, tableScanRowCount := distsqlCtx.RuntimeStatsColl.GetCopCountAndRows(tableScanCopID)
592-
idxResult := IndexRecordChunk{ID: task.ID, Chunk: srcChk, Done: done, ctx: w.ctx, tableScanRowCount: tableScanRowCount - lastTableScanRowCount, conditionPushed: conditionPushed}
577+
idxResults = append(idxResults, IndexRecordChunk{ID: task.ID, Chunk: srcChk, Done: done, ctx: w.ctx, tableScanRowCount: tableScanRowCount - lastTableScanRowCount, conditionPushed: conditionPushed})
593578
lastTableScanRowCount = tableScanRowCount
594-
if enableStreaming {
595-
sendResult(idxResult)
596-
} else {
597-
idxResults = append(idxResults, idxResult)
598-
}
599579
}
600580
return rs.Close()
601581
})
602582

603-
if !enableStreaming {
604-
for _, idxResult := range idxResults {
605-
sendResult(idxResult)
583+
for i, idxResult := range idxResults {
584+
sender(idxResult)
585+
if w.cpOp != nil {
586+
done := i == len(idxResults)-1
587+
w.cpOp.UpdateChunk(task.ID, int(idxResult.tableScanRowCount), done)
606588
}
589+
w.totalCount.Add(idxResult.tableScanRowCount)
607590
}
608591

609592
return err

pkg/distsql/context/BUILD.bazel

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ go_library(
1818
"//pkg/util/tiflash",
1919
"//pkg/util/topsql/stmtstats",
2020
"@com_github_tikv_client_go_v2//kv",
21-
"@com_github_tikv_client_go_v2//tikvrpc/interceptor",
2221
"@org_uber_go_atomic//:atomic",
2322
],
2423
)
@@ -43,7 +42,6 @@ go_test(
4342
"//pkg/util/tiflash",
4443
"//pkg/util/topsql/stmtstats",
4544
"@com_github_tikv_client_go_v2//kv",
46-
"@com_github_tikv_client_go_v2//tikvrpc/interceptor",
4745
"@org_uber_go_atomic//:atomic",
4846
],
4947
)

pkg/distsql/context/context.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ import (
2929
"github.com/pingcap/tidb/pkg/util/tiflash"
3030
"github.com/pingcap/tidb/pkg/util/topsql/stmtstats"
3131
tikvstore "github.com/tikv/client-go/v2/kv"
32-
"github.com/tikv/client-go/v2/tikvrpc/interceptor"
3332
"go.uber.org/atomic"
3433
)
3534

@@ -46,7 +45,6 @@ type DistSQLContext struct {
4645
KVVars *tikvstore.Variables
4746
KvExecCounter *stmtstats.KvExecCounter
4847
RUV2Metrics *execdetails.RUV2Metrics
49-
RUV2RPCInterceptor interceptor.RPCInterceptor
5048
SessionMemTracker *memory.Tracker
5149

5250
Location *time.Location

pkg/distsql/context/context_test.go

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ import (
3232
"github.com/pingcap/tidb/pkg/util/tiflash"
3333
"github.com/pingcap/tidb/pkg/util/topsql/stmtstats"
3434
tikvstore "github.com/tikv/client-go/v2/kv"
35-
"github.com/tikv/client-go/v2/tikvrpc/interceptor"
3635
"go.uber.org/atomic"
3736
)
3837

@@ -55,10 +54,7 @@ func TestContextDetach(t *testing.T) {
5554
KVVars: kvVars,
5655
KvExecCounter: &stmtstats.KvExecCounter{},
5756
RUV2Metrics: execdetails.NewRUV2Metrics(),
58-
RUV2RPCInterceptor: interceptor.NewRPCInterceptor("test", func(next interceptor.RPCInterceptorFunc) interceptor.RPCInterceptorFunc {
59-
return next
60-
}),
61-
SessionMemTracker: &memory.Tracker{},
57+
SessionMemTracker: &memory.Tracker{},
6258

6359
Location: time.Local,
6460
RuntimeStatsColl: &execdetails.RuntimeStatsColl{},
@@ -113,7 +109,6 @@ func TestContextDetach(t *testing.T) {
113109
"$.RunawayChecker",
114110
"$.RUConsumptionReporter",
115111
"$.ExecDetails",
116-
"$.RUV2RPCInterceptor",
117112
}))
118113

119114
staticObj := obj.Detach()
@@ -130,7 +125,6 @@ func TestContextDetach(t *testing.T) {
130125
"$.RUConsumptionReporter",
131126
"$.ExecDetails",
132127
"$.RUV2Metrics",
133-
"$.RUV2RPCInterceptor",
134128
"$.KVVars.Killed",
135129
"$.KvExecCounter",
136130
"$.SessionMemTracker",

pkg/distsql/distsql.go

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ func Select(ctx context.Context, dctx *distsqlctx.DistSQLContext, kvReq *kv.Requ
7878
}
7979

8080
ctx = WithSQLKvExecCounterInterceptor(ctx, dctx.KvExecCounter)
81-
ctx = WithRUV2MetricsInterceptor(ctx, dctx.RUV2RPCInterceptor)
8281
option := &kv.ClientSendOption{
8382
SessionMemTracker: dctx.SessionMemTracker,
8483
EnabledRateLimitAction: enabledRateLimitAction,
@@ -178,7 +177,6 @@ func SelectWithRuntimeStats(ctx context.Context, dctx *distsqlctx.DistSQLContext
178177
func Analyze(ctx context.Context, client kv.Client, kvReq *kv.Request, vars any,
179178
isRestrict bool, dctx *distsqlctx.DistSQLContext) (SelectResult, error) {
180179
ctx = WithSQLKvExecCounterInterceptor(ctx, dctx.KvExecCounter)
181-
ctx = WithRUV2MetricsInterceptor(ctx, dctx.RUV2RPCInterceptor)
182180
failpoint.Inject("mockAnalyzeRequestWaitForCancel", func(val failpoint.Value) {
183181
if val.(bool) {
184182
<-ctx.Done()
@@ -290,12 +288,3 @@ func WithSQLKvExecCounterInterceptor(ctx context.Context, counter *stmtstats.KvE
290288
}
291289
return ctx
292290
}
293-
294-
// WithRUV2MetricsInterceptor binds an interceptor for client-go to collect
295-
// statement-level RUv2 request counters and TiKV ExecDetailsV2-based metrics.
296-
func WithRUV2MetricsInterceptor(ctx context.Context, ruv2Interceptor interceptor.RPCInterceptor) context.Context {
297-
if ruv2Interceptor != nil {
298-
return interceptor.WithRPCInterceptor(ctx, ruv2Interceptor)
299-
}
300-
return ctx
301-
}

pkg/executor/adapter.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1717,6 +1717,7 @@ func (a *ExecStmt) finalizeStatementRUV2Metrics() {
17171717
if ruDetail == nil {
17181718
return
17191719
}
1720+
execdetails.SyncRUV2MetricsFromRUDetails(sessVars.RUV2Metrics, ruDetail)
17201721

17211722
weights := sessVars.RUV2Weights()
17221723
tidbRU := sessVars.RUV2Metrics.CalculateRUValues(weights)

pkg/executor/adapter_test.go

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
"time"
2525

2626
"github.com/pingcap/failpoint"
27+
"github.com/pingcap/kvproto/pkg/kvrpcpb"
2728
rmpb "github.com/pingcap/kvproto/pkg/resource_manager"
2829
"github.com/pingcap/tidb/pkg/config"
2930
distsqlctx "github.com/pingcap/tidb/pkg/distsql/context"
@@ -453,7 +454,7 @@ func TestWriteSlowLog(t *testing.T) {
453454
checkWriteSlowLog(true)
454455
}
455456

456-
func TestFinishExecuteStmtReportsTiDBRUV2WithoutSyncingRUDetails(t *testing.T) {
457+
func TestFinishExecuteStmtSyncsTiDBRUV2FromRUDetails(t *testing.T) {
457458
original := config.GetGlobalConfig()
458459
originalGenerateBinaryPlan := variable.GenerateBinaryPlan.Load()
459460
t.Cleanup(func() {
@@ -488,11 +489,16 @@ func TestFinishExecuteStmtReportsTiDBRUV2WithoutSyncingRUDetails(t *testing.T) {
488489
sessVars.RUV2Metrics.AddResultChunkCells(100)
489490
sessVars.RUV2Metrics.AddPlanCnt(2)
490491
sessVars.RUV2Metrics.AddSessionParserTotal(3)
491-
492-
expected := sessVars.RUV2Metrics.CalculateRUValues(sessVars.RUV2Weights())
493492
ruDetails := goCtx.Value(util.RUDetailsCtxKey).(*util.RUDetails)
494493
ruDetails.AddTiKVRUV2(23456)
494+
ruDetails.AddRUV2(&kvrpcpb.RUV2{
495+
ReadRpcCount: 5,
496+
WriteRpcCount: 7,
497+
StorageProcessedKeysBatchGet: 11,
498+
})
495499
ruDetails.UpdateTiFlash(&rmpb.Consumption{RRU: 345, WRU: 67})
500+
expected := sessVars.RUV2Metrics.Clone()
501+
execdetails.SyncRUV2MetricsFromRUDetails(expected, ruDetails)
496502

497503
execStmt := &executor.ExecStmt{
498504
Ctx: ctx,
@@ -502,9 +508,12 @@ func TestFinishExecuteStmtReportsTiDBRUV2WithoutSyncingRUDetails(t *testing.T) {
502508
execStmt.FinishExecuteStmt(0, nil, false)
503509

504510
require.Equal(t, float64(23456), ruDetails.TiKVRUV2())
511+
require.Equal(t, int64(5), sessVars.RUV2Metrics.ResourceManagerReadCnt())
512+
require.Equal(t, int64(7), sessVars.RUV2Metrics.ResourceManagerWriteCnt())
513+
require.Equal(t, int64(11), sessVars.RUV2Metrics.TiKVStorageProcessedKeysBatchGet())
505514
require.Equal(t, "rg1", reporter.group)
506515
require.Equal(t, float64(23456), reporter.tikvRUV2)
507-
require.Equal(t, expected, reporter.tidbRUV2)
516+
require.Equal(t, expected.CalculateRUValues(sessVars.RUV2Weights()), reporter.tidbRUV2)
508517
require.Equal(t, float64(412), reporter.tiflashRU)
509518

510519
t.Run("stmt summary ignores optimistic autocommit retry count", func(t *testing.T) {

0 commit comments

Comments
 (0)