Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions DEPS.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -3777,8 +3777,8 @@ def go_deps():
name = "com_github_pingcap_kvproto",
build_file_proto_mode = "disable_global",
importpath = "github.com/pingcap/kvproto",
sum = "h1:MalBpLjhK/cS9ndCoSAg2C7aBzVojAqFVfzTKmuy0ho=",
version = "v0.0.0-20260622063236-b41e86365ce0",
sum = "h1:qW0gHsqY3X3qmyiEfESqpYSF3Vu7agUiAyBnPWQXtm8=",
version = "v0.0.0-20260721064811-683dad8fa368",
)
go_repository(
name = "com_github_pingcap_log",
Expand Down Expand Up @@ -4492,8 +4492,8 @@ def go_deps():
build_tags = ["nextgen", "intest"],
build_file_proto_mode = "disable_global",
importpath = "github.com/tikv/client-go/v2",
sum = "h1:Ju9uUKu3M5gPl7Z90e9dcGSe8LtXxGqvSetbPcr6tyc=",
version = "v2.0.8-0.20260708122311-01bd8f99f4da",
sum = "h1:zku+59sqBs1v9Fvl39FFjDUivvRkKvfhXnYgePdotr8=",
version = "v2.0.8-0.20260724023932-61ecd7c11416",
)
go_repository(
name = "com_github_tikv_pd_client",
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ require (
github.com/pingcap/errors v0.11.5-0.20260508054701-306e305bcf41
github.com/pingcap/failpoint v0.0.0-20240528011301-b51a646c7c86
github.com/pingcap/fn v1.0.0
github.com/pingcap/kvproto v0.0.0-20260622063236-b41e86365ce0
github.com/pingcap/kvproto v0.0.0-20260721064811-683dad8fa368
github.com/pingcap/log v1.1.1-0.20250917021125-19901e015dc9
github.com/pingcap/metering_sdk v0.0.0-20260324055927-14fead745f1d
github.com/pingcap/sysutil v1.0.1-0.20240311050922-ae81ee01f3a5
Expand All @@ -122,7 +122,7 @@ require (
github.com/stathat/consistent v1.0.0
github.com/stretchr/testify v1.11.1
github.com/tiancaiamao/appdash v0.0.0-20181126055449-889f96f722a2
github.com/tikv/client-go/v2 v2.0.8-0.20260708122311-01bd8f99f4da
github.com/tikv/client-go/v2 v2.0.8-0.20260724023932-61ecd7c11416
github.com/tikv/pd/client v0.0.0-20260708075407-4e05b9d2c2d3
github.com/timakin/bodyclose v0.0.0-20241222091800-1db5c5ca4d67
github.com/twmb/murmur3 v1.1.6
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2174,8 +2174,8 @@ github.com/pingcap/fn v1.0.0/go.mod h1:u9WZ1ZiOD1RpNhcI42RucFh/lBuzTu6rw88a+oF2Z
github.com/pingcap/goleveldb v0.0.0-20191226122134-f82aafb29989 h1:surzm05a8C9dN8dIUmo4Be2+pMRb6f55i+UIYrluu2E=
github.com/pingcap/goleveldb v0.0.0-20191226122134-f82aafb29989/go.mod h1:O17XtbryoCJhkKGbT62+L2OlrniwqiGLSqrmdHCMzZw=
github.com/pingcap/kvproto v0.0.0-20191211054548-3c6b38ea5107/go.mod h1:WWLmULLO7l8IOcQG+t+ItJ3fEcrL5FxF0Wu+HrMy26w=
github.com/pingcap/kvproto v0.0.0-20260622063236-b41e86365ce0 h1:MalBpLjhK/cS9ndCoSAg2C7aBzVojAqFVfzTKmuy0ho=
github.com/pingcap/kvproto v0.0.0-20260622063236-b41e86365ce0/go.mod h1:z6+aAHB7dBkA+LyinEX+48/ImRJ3jag0Hg0c7wkhEvE=
github.com/pingcap/kvproto v0.0.0-20260721064811-683dad8fa368 h1:qW0gHsqY3X3qmyiEfESqpYSF3Vu7agUiAyBnPWQXtm8=
github.com/pingcap/kvproto v0.0.0-20260721064811-683dad8fa368/go.mod h1:z6+aAHB7dBkA+LyinEX+48/ImRJ3jag0Hg0c7wkhEvE=
github.com/pingcap/log v0.0.0-20210625125904-98ed8e2eb1c7/go.mod h1:8AanEdAHATuRurdGxZXBz0At+9avep+ub7U1AGYLIMM=
github.com/pingcap/log v1.1.0/go.mod h1:DWQW5jICDR7UJh4HtxXSM20Churx4CQL0fwL/SoOSA4=
github.com/pingcap/log v1.1.1-0.20250917021125-19901e015dc9 h1:qG9BSvlWFEE5otQGamuWedx9LRm0nrHvsQRQiW8SxEs=
Expand Down Expand Up @@ -2358,8 +2358,8 @@ github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4=
github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
github.com/tidwall/sjson v1.2.5 h1:kLy8mja+1c9jlljvWTlSazM7cKDRfJuR/bOJhcY5NcY=
github.com/tidwall/sjson v1.2.5/go.mod h1:Fvgq9kS/6ociJEDnK0Fk1cpYF4FIW6ZF7LAe+6jwd28=
github.com/tikv/client-go/v2 v2.0.8-0.20260708122311-01bd8f99f4da h1:Ju9uUKu3M5gPl7Z90e9dcGSe8LtXxGqvSetbPcr6tyc=
github.com/tikv/client-go/v2 v2.0.8-0.20260708122311-01bd8f99f4da/go.mod h1:MRhIujZMMkYcI49Euif4+A3+SHSGwTpyUUadNz48R4g=
github.com/tikv/client-go/v2 v2.0.8-0.20260724023932-61ecd7c11416 h1:zku+59sqBs1v9Fvl39FFjDUivvRkKvfhXnYgePdotr8=
github.com/tikv/client-go/v2 v2.0.8-0.20260724023932-61ecd7c11416/go.mod h1:JTi9j45KOswYaMEEawAItWPAlZirDAGteZZMDwOo3fE=
github.com/tikv/pd/client v0.0.0-20260708075407-4e05b9d2c2d3 h1:OoBvgoeWmdNEXtS+eOlhysz/OvhA4GS0OdPVhTXteGA=
github.com/tikv/pd/client v0.0.0-20260708075407-4e05b9d2c2d3/go.mod h1:3/Bu91CJONgkDA+Y0v/cnbROSJnu5tQ09vv7JGybUBA=
github.com/timakin/bodyclose v0.0.0-20241222091800-1db5c5ca4d67 h1:9LPGD+jzxMlnk5r6+hJnar67cgpDIz/iyD+rfl5r2Vk=
Expand Down
21 changes: 19 additions & 2 deletions pkg/distsql/select_result.go
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,7 @@ func (r *selectResult) fetchRespWithIntermediateResults(ctx context.Context, int
if hasStats, ok := resultSubset.(CopRuntimeStats); ok {
if copStats := hasStats.GetCopRuntimeStats(); copStats != nil {
r.ctx.ExecDetails.MergeCopExecDetails(&copStats.CopExecDetails, duration)
r.ctx.ExecDetails.MergeReadPoolTaskDetails(copStats.ReadPoolTaskDetails)
}
}
}
Expand Down Expand Up @@ -475,6 +476,7 @@ func (r *selectResult) fetchRespWithIntermediateResults(ctx context.Context, int
return err
}
r.ctx.ExecDetails.MergeCopExecDetails(&copStats.CopExecDetails, duration)
r.ctx.ExecDetails.MergeReadPoolTaskDetails(copStats.ReadPoolTaskDetails)
}
}
if len(r.selectResp.Chunks) != 0 {
Expand Down Expand Up @@ -685,7 +687,14 @@ func (r *selectResult) updateCopRuntimeStats(ctx context.Context, copStats *copr
}
if hasExecutor {
if len(r.copPlanIDs) > 0 {
r.ctx.RuntimeStatsColl.RecordCopStats(r.copPlanIDs[len(r.copPlanIDs)-1], r.storeType, copStats.ScanDetail, copStats.TimeDetail, nil)
r.ctx.RuntimeStatsColl.RecordCopStats(
r.copPlanIDs[len(r.copPlanIDs)-1],
r.storeType,
copStats.ScanDetail,
copStats.TimeDetail,
copStats.ReadPoolTaskDetails,
nil,
)
}
recordExecutionSummariesForTiFlashTasks(r.ctx.RuntimeStatsColl, r.selectResp.GetExecutionSummaries(), r.storeType, r.copPlanIDs)
// report MPP cross AZ network traffic bytes to resource control manager.
Expand Down Expand Up @@ -719,7 +728,14 @@ func (r *selectResult) updateCopRuntimeStats(ctx context.Context, copStats *copr
}
planID := r.copPlanIDs[i]
if i == len(r.copPlanIDs)-1 {
r.ctx.RuntimeStatsColl.RecordCopStats(planID, r.storeType, copStats.ScanDetail, copStats.TimeDetail, summary)
r.ctx.RuntimeStatsColl.RecordCopStats(
planID,
r.storeType,
copStats.ScanDetail,
copStats.TimeDetail,
copStats.ReadPoolTaskDetails,
summary,
)
} else if summary != nil {
r.ctx.RuntimeStatsColl.RecordOneCopTask(planID, r.storeType, summary)
}
Expand Down Expand Up @@ -769,6 +785,7 @@ func (r *selectResult) close() error {
for _, copStats := range unconsumedCopStats {
_ = r.updateCopRuntimeStats(context.Background(), copStats, time.Duration(0), true)
r.ctx.ExecDetails.MergeCopExecDetails(&copStats.CopExecDetails, 0)
r.ctx.ExecDetails.MergeReadPoolTaskDetails(copStats.ReadPoolTaskDetails)
}
}
}
Expand Down
1 change: 1 addition & 0 deletions pkg/executor/batch_point_get.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ func (e *BatchPointGetExec) Close() error {
if e.RuntimeStats() != nil {
defer func() {
sc := e.Ctx().GetSessionVars().StmtCtx
sc.MergeReadPoolTaskDetails(e.stats.SnapshotRuntimeStats.GetReadPoolTaskDetails())
sc.RuntimeStatsColl.RegisterStats(e.ID(), e.stats)
timeDetail := e.stats.SnapshotRuntimeStats.GetTimeDetail()
if timeDetail != nil {
Expand Down
1 change: 1 addition & 0 deletions pkg/executor/point_get.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ func (e *PointGetExecutor) Close() error {
if e.stats != nil {
defer func() {
sc := e.Ctx().GetSessionVars().StmtCtx
sc.MergeReadPoolTaskDetails(e.stats.SnapshotRuntimeStats.GetReadPoolTaskDetails())
sc.RuntimeStatsColl.RegisterStats(e.ID(), e.stats)
timeDetail := e.stats.SnapshotRuntimeStats.GetTimeDetail()
if timeDetail != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/executor/slow_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -1156,7 +1156,7 @@ func getColumnValueFactoryByName(colName string, columnIdx int) (slowQueryColumn
case variable.SlowLogUserStr, variable.SlowLogHostStr, execdetails.BackoffTypesStr, variable.SlowLogDBStr, variable.SlowLogIndexNamesStr, variable.SlowLogDigestStr,
variable.SlowLogStatsInfoStr, variable.SlowLogCopProcAddr, variable.SlowLogCopWaitAddr, variable.SlowLogPlanDigest,
variable.SlowLogPrevStmt, variable.SlowLogQuerySQLStr, variable.SlowLogWarnings, variable.SlowLogSessAliasStr,
variable.SlowLogResourceGroup, variable.SlowLogRequestUnitV2Detail:
variable.SlowLogResourceGroup, variable.SlowLogRequestUnitV2Detail, execdetails.ReadPoolTaskDetailsStr:
return func(row []types.Datum, value string, _ *time.Location, _ *slowLogChecker) (valid bool, err error) {
row[columnIdx] = types.NewStringDatum(value)
return true, nil
Expand Down
143 changes: 143 additions & 0 deletions pkg/executor/slow_query_sql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,27 @@ import (
"fmt"
"math"
"os"
"strings"
"testing"
"time"

"github.com/pingcap/failpoint"
"github.com/pingcap/kvproto/pkg/coprocessor"
"github.com/pingcap/kvproto/pkg/kvrpcpb"
"github.com/pingcap/tidb/pkg/config"
"github.com/pingcap/tidb/pkg/executor"
"github.com/pingcap/tidb/pkg/meta/model"
"github.com/pingcap/tidb/pkg/parser/ast"
"github.com/pingcap/tidb/pkg/parser/auth"
"github.com/pingcap/tidb/pkg/store/mockstore"
"github.com/pingcap/tidb/pkg/store/mockstore/unistore"
"github.com/pingcap/tidb/pkg/testkit"
"github.com/pingcap/tidb/pkg/testkit/external"
"github.com/pingcap/tidb/pkg/testkit/testdata"
"github.com/pingcap/tidb/pkg/testkit/testutil"
"github.com/pingcap/tidb/pkg/util/logutil"
"github.com/stretchr/testify/require"
"github.com/tikv/client-go/v2/tikvrpc"
)

func TestSlowQueryWithoutSlowLog(t *testing.T) {
Expand Down Expand Up @@ -553,6 +559,143 @@ func TestStorageEnginesInSlowQuery(t *testing.T) {
checkStorageEngines(t, tk, "query like 'select%tablesample%;'", "1 0")
}

func TestReadPoolTaskDetailsInDiagnostics(t *testing.T) {
originCfg := config.GetGlobalConfig()
newCfg := *originCfg
f, err := os.CreateTemp("", "tidb-slow-*.log")
require.NoError(t, err)
newCfg.Log.SlowQueryFile = f.Name()
config.StoreGlobalConfig(&newCfg)
t.Cleanup(func() {
if t.Failed() {
if data, err := os.ReadFile(f.Name()); err == nil {
t.Logf("slow log contents (%d bytes):\n%s", len(data), data)
}
}
config.StoreGlobalConfig(originCfg)
require.NoError(t, f.Close())
require.NoError(t, os.Remove(f.Name()))
})
require.NoError(t, logutil.InitLogger(newCfg.Log.ToLogConfig()))

store := testkit.CreateMockStore(t)
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
tk.MustExec(fmt.Sprintf("set @@tidb_slow_query_file='%v'", f.Name()))
tk.MustExec("set tidb_slow_log_threshold=0")
tk.MustExec("set tidb_enable_paging=0")
t.Cleanup(func() {
tk.MustExec("set tidb_slow_log_threshold=300")
})

tk.MustExec("create table t_read_pool_details (id int primary key, v int)")
tk.MustExec("insert into t_read_pool_details values (1, 10), (2, 20), (3, 30)")

responseHook := func(_ *tikvrpc.Request, resp *tikvrpc.Response) {
newExecDetails := func() *kvrpcpb.ExecDetailsV2 {
return &kvrpcpb.ExecDetailsV2{
ReadPoolTaskDetails: &kvrpcpb.PoolTaskDetails{
PollCount: 4,
DispatchCount: 2,
TotalWallNanos: uint64((20 * time.Millisecond).Nanoseconds()),
TotalQueueWaitNanos: uint64((6 * time.Millisecond).Nanoseconds()),
MaxQueueWaitNanos: uint64((4 * time.Millisecond).Nanoseconds()),
MinQueueWaitNanos: uint64((2 * time.Millisecond).Nanoseconds()),
TotalWakeWaitNanos: uint64((4 * time.Millisecond).Nanoseconds()),
MaxWakeWaitNanos: uint64((4 * time.Millisecond).Nanoseconds()),
MinWakeWaitNanos: uint64((4 * time.Millisecond).Nanoseconds()),
FairQueueEnabled: true,
TotalFairQueueWaitedTaskSlices: 6,
MaxFairQueueWaitedTaskSlices: 4,
MinFairQueueWaitedTaskSlices: 2,
PollCpuNanos: uint64((8 * time.Millisecond).Nanoseconds()),
MaxPollCpuNanos: uint64((3 * time.Millisecond).Nanoseconds()),
MinPollCpuNanos: uint64((1 * time.Millisecond).Nanoseconds()),
PollWallNanos: uint64((12 * time.Millisecond).Nanoseconds()),
MaxPollWallNanos: uint64((5 * time.Millisecond).Nanoseconds()),
MinPollWallNanos: uint64((2 * time.Millisecond).Nanoseconds()),
},
}
}

switch typedResp := resp.Resp.(type) {
case *kvrpcpb.GetResponse:
typedResp.ExecDetailsV2 = newExecDetails()
case *kvrpcpb.BatchGetResponse:
typedResp.ExecDetailsV2 = newExecDetails()
case *coprocessor.Response:
typedResp.ExecDetailsV2 = newExecDetails()
}
}
unistore.UnistoreRPCClientResponseHook.Store(&responseHook)
require.NoError(t, failpoint.Enable(
"github.com/pingcap/tidb/pkg/store/mockstore/unistore/unistoreRPCClientResponseHook",
"return(true)",
))
t.Cleanup(func() {
unistore.UnistoreRPCClientResponseHook.Store(nil)
require.NoError(t, failpoint.Disable(
"github.com/pingcap/tidb/pkg/store/mockstore/unistore/unistoreRPCClientResponseHook",
))
})

const expectedDetails = "{tasks:1, poll_count:{total:4, avg:4, max:4, min:4}, " +
"dispatch_count:{total:2, max:2, min:2}, " +
"task_wall_time:{total:20ms, avg:20ms, max:20ms, min:20ms}, " +
"queue_wait:{total:6ms, avg:3ms, max:4ms, min:2ms}, " +
"wake_wait:{total:4ms, avg:4ms, max:4ms, min:4ms}, " +
"fair_queue:{enabled:true, waited_task_slices:{total:6, avg:3, max:4, min:2}}, " +
"poll_cpu:{total:8ms, avg:2ms, max:3ms, min:1ms}, " +
"poll_wall:{total:12ms, avg:3ms, max:5ms, min:2ms}}"
cases := []struct {
name string
plan string
sql string
}{
{
name: "point get",
plan: "Point_Get",
sql: "select /* read_pool_point_get */ * from t_read_pool_details where id = 1",
},
{
name: "batch point get",
plan: "Batch_Point_Get",
sql: "select /* read_pool_batch_point_get */ * from t_read_pool_details where id in (1, 2)",
},
{
name: "cop task",
plan: "TableReader",
sql: "select /* read_pool_cop */ * from t_read_pool_details where v >= 10",
},
}

for _, testCase := range cases {
t.Run(testCase.name, func(t *testing.T) {
tk.MustHavePlan(testCase.sql, testCase.plan)
tk.MustQuery(testCase.sql)
tk.EventuallyMustQueryAndCheck(
"select read_pool_task_details from information_schema.slow_query "+
"where query = '"+testCase.sql+";' "+
"order by time desc limit 1",
nil,
testkit.Rows(expectedDetails),
2*time.Second,
50*time.Millisecond,
)

rows := tk.MustQuery("explain analyze " + testCase.sql).Rows()
foundDetails := false
for _, row := range rows {
if strings.Contains(fmt.Sprint(row[5]), "read_pool:"+expectedDetails) {
foundDetails = true
break
}
}
require.True(t, foundDetails, "read-pool task details not found in EXPLAIN ANALYZE output: %v", rows)
})
}
}

func TestSessionConnectAttrsInSlowQuery(t *testing.T) {
originCfg := config.GetGlobalConfig()
newCfg := *originCfg
Expand Down
8 changes: 4 additions & 4 deletions pkg/executor/slow_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ select * from t;`
}
expectRecordString := `2019-04-28 15:24:04.309074,` +
`405888132465033227,root,localhost,0,alias123,57,0.12,0.216905,` +
`0,0,0,0,0,0,0,0,0,0,0,0,,0,0,0,0,0,0,0.38,0.021,0,0,0,1,637,0,10,10,10,10,100,4,4096,0.015,,,1,42a1c8aae6f133e934d4bf0147491709a8812ea05ff8819ec522780fe657b772,t1:1,t2:2,` +
`0,0,0,0,0,0,0,0,0,0,0,0,,0,0,0,0,0,0,0.38,0.021,0,0,0,1,637,0,10,10,10,10,100,4,4096,0.015,,,,1,42a1c8aae6f133e934d4bf0147491709a8812ea05ff8819ec522780fe657b772,t1:1,t2:2,` +
`0.1,0.2,0.03,127.0.0.1:20160,0.05,0.6,0.8,0.0.0.0:20160,70724,23333,65536,0,0,0,30000,3000,10000,1000,500000,500005,300000,300005,0,0,,` +
`Cop_backoff_regionMiss_total_times: 200 Cop_backoff_regionMiss_total_time: 0.2 Cop_backoff_regionMiss_max_time: 0.2 Cop_backoff_regionMiss_max_addr: 127.0.0.1 Cop_backoff_regionMiss_avg_time: 0.2 Cop_backoff_regionMiss_p90_time: 0.2 Cop_backoff_rpcPD_total_times: 200 Cop_backoff_rpcPD_total_time: 0.2 Cop_backoff_rpcPD_max_time: 0.2 Cop_backoff_rpcPD_max_addr: 127.0.0.1 Cop_backoff_rpcPD_avg_time: 0.2 Cop_backoff_rpcPD_p90_time: 0.2 Cop_backoff_rpcTiKV_total_times: 200 Cop_backoff_rpcTiKV_total_time: 0.2 Cop_backoff_rpcTiKV_max_time: 0.2 Cop_backoff_rpcTiKV_max_addr: 127.0.0.1 Cop_backoff_rpcTiKV_avg_time: 0.2 Cop_backoff_rpcTiKV_p90_time: 0.2,` +
`0,0,1,0,1,1,0,default,2.158,2.123,0.05,0.01,0.021,1,1,150,total_ru:150.00, tidb_ru:0.00, tikv_ru:100.00, tiflash_ru:50.00,,60e9378c746d9a2be1c791047e008967cf252eb6de9167ad3aa6098fa2d523f4,` +
Expand All @@ -217,7 +217,7 @@ select * from t;`
}
expectRecordString = `2019-04-28 15:24:04.309074,` +
`405888132465033227,root,localhost,0,alias123,57,0.12,0.216905,` +
`0,0,0,0,0,0,0,0,0,0,0,0,,0,0,0,0,0,0,0.38,0.021,0,0,0,1,637,0,10,10,10,10,100,4,4096,0.015,,,1,42a1c8aae6f133e934d4bf0147491709a8812ea05ff8819ec522780fe657b772,t1:1,t2:2,` +
`0,0,0,0,0,0,0,0,0,0,0,0,,0,0,0,0,0,0,0.38,0.021,0,0,0,1,637,0,10,10,10,10,100,4,4096,0.015,,,,1,42a1c8aae6f133e934d4bf0147491709a8812ea05ff8819ec522780fe657b772,t1:1,t2:2,` +
`0.1,0.2,0.03,127.0.0.1:20160,0.05,0.6,0.8,0.0.0.0:20160,70724,23333,65536,0,0,0,30000,3000,10000,1000,500000,500005,300000,300005,0,0,,` +
`Cop_backoff_regionMiss_total_times: 200 Cop_backoff_regionMiss_total_time: 0.2 Cop_backoff_regionMiss_max_time: 0.2 Cop_backoff_regionMiss_max_addr: 127.0.0.1 Cop_backoff_regionMiss_avg_time: 0.2 Cop_backoff_regionMiss_p90_time: 0.2 Cop_backoff_rpcPD_total_times: 200 Cop_backoff_rpcPD_total_time: 0.2 Cop_backoff_rpcPD_max_time: 0.2 Cop_backoff_rpcPD_max_addr: 127.0.0.1 Cop_backoff_rpcPD_avg_time: 0.2 Cop_backoff_rpcPD_p90_time: 0.2 Cop_backoff_rpcTiKV_total_times: 200 Cop_backoff_rpcTiKV_total_time: 0.2 Cop_backoff_rpcTiKV_max_time: 0.2 Cop_backoff_rpcTiKV_max_addr: 127.0.0.1 Cop_backoff_rpcTiKV_avg_time: 0.2 Cop_backoff_rpcTiKV_p90_time: 0.2,` +
`0,0,1,0,1,1,0,default,2.158,2.123,0.05,0.01,0.021,1,1,150,total_ru:150.00, tidb_ru:0.00, tikv_ru:100.00, tiflash_ru:50.00,,60e9378c746d9a2be1c791047e008967cf252eb6de9167ad3aa6098fa2d523f4,` +
Expand Down Expand Up @@ -285,9 +285,9 @@ select * from t;
rows, err = parseSlowLog(ctx, reader)
require.NoError(t, err)
require.Len(t, rows, 1)
value, _ := rows[0][44].ToString()
value, _ := rows[0][45].ToString()
require.Equal(t, value, "a: b")
value, _ = rows[0][45].ToString()
value, _ = rows[0][46].ToString()
require.Equal(t, value, "[t:i: a]")
}

Expand Down
1 change: 1 addition & 0 deletions pkg/infoschema/tables.go
Original file line number Diff line number Diff line change
Expand Up @@ -939,6 +939,7 @@ var slowQueryCols = []columnInfo{
{name: execdetails.IARemoteReadSegmentCountStr, tp: mysql.TypeLonglong, size: 20, flag: mysql.UnsignedFlag},
{name: execdetails.IARemoteReadSegmentSizeStr, tp: mysql.TypeLonglong, size: 20, flag: mysql.UnsignedFlag},
{name: execdetails.IARemoteReadSegmentWaitTimeStr, tp: mysql.TypeDouble, size: 22},
{name: execdetails.ReadPoolTaskDetailsStr, tp: mysql.TypeLongBlob, size: types.UnspecifiedLength},
{name: variable.SlowLogDBStr, tp: mysql.TypeVarchar, size: 64},
{name: variable.SlowLogIndexNamesStr, tp: mysql.TypeVarchar, size: 100},
{name: variable.SlowLogIsInternalStr, tp: mysql.TypeTiny, size: 1},
Expand Down
2 changes: 2 additions & 0 deletions pkg/infoschema/test/clustertablestest/tables_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,7 @@ func TestSlowQuery(t *testing.T) {
"0",
"0",
"0",
"",
"test",
"",
"0",
Expand Down Expand Up @@ -552,6 +553,7 @@ func TestSlowQuery(t *testing.T) {
"0",
"0",
"0",
"",
"rtdb",
"",
"0",
Expand Down
9 changes: 8 additions & 1 deletion pkg/store/copr/coprocessor.go
Original file line number Diff line number Diff line change
Expand Up @@ -2674,6 +2674,12 @@ func (worker *copIteratorWorker) collectCopRuntimeStats(copStats *CopRuntimeStat
if scanDetailV2 := pbDetails.ScanDetailV2; scanDetailV2 != nil {
copStats.ScanDetail.MergeFromScanDetailV2(scanDetailV2)
}
if readPoolTaskDetails := pbDetails.GetReadPoolTaskDetails(); readPoolTaskDetails != nil {
if copStats.ReadPoolTaskDetails == nil {
copStats.ReadPoolTaskDetails = &util.PoolTaskDetails{}
}
copStats.ReadPoolTaskDetails.MergeFromPB(readPoolTaskDetails)
}
} else if pbDetails := resp.pbResp.ExecDetails; pbDetails != nil {
if timeDetail := pbDetails.TimeDetail; timeDetail != nil {
copStats.TimeDetail.MergeFromTimeDetail(nil, timeDetail)
Expand Down Expand Up @@ -2734,7 +2740,8 @@ func (worker *copIteratorWorker) collectUnconsumedCopRuntimeStats(bo *Backoffer,
// CopRuntimeStats contains execution detail information.
type CopRuntimeStats struct {
execdetails.CopExecDetails
ReqStats *tikv.RegionRequestRuntimeStats
ReqStats *tikv.RegionRequestRuntimeStats
ReadPoolTaskDetails *util.PoolTaskDetails

CoprCacheHit bool
}
Expand Down
Loading
Loading