diff --git a/DEPS.bzl b/DEPS.bzl index 55923713a952a..0ab668a61e0f5 100644 --- a/DEPS.bzl +++ b/DEPS.bzl @@ -3703,8 +3703,8 @@ def go_deps(): name = "com_github_tikv_client_go_v2", build_file_proto_mode = "disable_global", importpath = "github.com/tikv/client-go/v2", - sum = "h1:u21KmROEJmJL+Wkqz4cUe2BpjmcobqsYVNGEbVWKmnU=", - version = "v2.0.4-0.20230829002742-dfae543556aa", + sum = "h1:tayF5Szzeemsrgmup5dh5Uom4BiwzmYTMQ84NdrA+68=", + version = "v2.0.4-0.20230918031736-9126d0716e90", ) go_repository( name = "com_github_tikv_pd_client", diff --git a/go.mod b/go.mod index eafdea79a3c65..dbdc9bcf0fc24 100644 --- a/go.mod +++ b/go.mod @@ -90,7 +90,7 @@ require ( github.com/stretchr/testify v1.8.0 github.com/tdakkota/asciicheck v0.1.1 github.com/tiancaiamao/appdash v0.0.0-20181126055449-889f96f722a2 - github.com/tikv/client-go/v2 v2.0.4-0.20230915073153-7f7f0549611a + github.com/tikv/client-go/v2 v2.0.4-0.20230918031736-9126d0716e90 github.com/tikv/pd/client v0.0.0-20221031025758-80f0d8ca4d07 github.com/timakin/bodyclose v0.0.0-20210704033933-f49887972144 github.com/twmb/murmur3 v1.1.3 diff --git a/go.sum b/go.sum index fc9d6690465fb..a5dfc9c231375 100644 --- a/go.sum +++ b/go.sum @@ -935,8 +935,8 @@ github.com/tenntenn/text/transform v0.0.0-20200319021203-7eef512accb3 h1:f+jULpR github.com/tenntenn/text/transform v0.0.0-20200319021203-7eef512accb3/go.mod h1:ON8b8w4BN/kE1EOhwT0o+d62W65a6aPw1nouo9LMgyY= github.com/tiancaiamao/appdash v0.0.0-20181126055449-889f96f722a2 h1:mbAskLJ0oJfDRtkanvQPiooDH8HvJ2FBh+iKT/OmiQQ= github.com/tiancaiamao/appdash v0.0.0-20181126055449-889f96f722a2/go.mod h1:2PfKggNGDuadAa0LElHrByyrz4JPZ9fFx6Gs7nx7ZZU= -github.com/tikv/client-go/v2 v2.0.4-0.20230915073153-7f7f0549611a h1:19SpfhQbXO+rVqZbyWoU08CprQtUVIMhDMQ0R7zajAw= -github.com/tikv/client-go/v2 v2.0.4-0.20230915073153-7f7f0549611a/go.mod h1:mmVCLP2OqWvQJPOIevQPZvGphzh/oq9vv8J5LDfpadQ= +github.com/tikv/client-go/v2 v2.0.4-0.20230918031736-9126d0716e90 h1:tayF5Szzeemsrgmup5dh5Uom4BiwzmYTMQ84NdrA+68= +github.com/tikv/client-go/v2 v2.0.4-0.20230918031736-9126d0716e90/go.mod h1:mmVCLP2OqWvQJPOIevQPZvGphzh/oq9vv8J5LDfpadQ= github.com/tikv/pd/client v0.0.0-20221031025758-80f0d8ca4d07 h1:ckPpxKcl75mO2N6a4cJXiZH43hvcHPpqc9dh1TmH1nc= github.com/tikv/pd/client v0.0.0-20221031025758-80f0d8ca4d07/go.mod h1:CipBxPfxPUME+BImx9MUYXCnAVLS3VJUr3mnSJwh40A= github.com/timakin/bodyclose v0.0.0-20210704033933-f49887972144 h1:kl4KhGNsJIbDHS9/4U9yQo1UcPQM0kOMJHn29EoH/Ro= diff --git a/session/session.go b/session/session.go index c705acd0ce1b2..52a543a3afd04 100644 --- a/session/session.go +++ b/session/session.go @@ -4173,9 +4173,8 @@ func (s *session) setRequestSource(ctx context.Context, stmtLabel string, stmtNo if !s.isInternal() { if txn, _ := s.Txn(false); txn != nil && txn.Valid() { txn.SetOption(kv.RequestSourceType, stmtLabel) - } else { - s.sessionVars.RequestSourceType = stmtLabel } + s.sessionVars.RequestSourceType = stmtLabel return } if source := ctx.Value(kv.RequestSourceKey); source != nil { diff --git a/store/copr/coprocessor.go b/store/copr/coprocessor.go index 7e89f44584b9c..2a752f035ede6 100644 --- a/store/copr/coprocessor.go +++ b/store/copr/coprocessor.go @@ -272,6 +272,8 @@ type copTask struct { // timeout value for one kv readonly request tikvClientReadTimeout uint64 + // firstReadType is used to indicate the type of first read when retrying. + firstReadType string } type batchedCopTask struct { @@ -1022,13 +1024,17 @@ func (worker *copIteratorWorker) handleTaskOnce(bo *Backoffer, task *copTask, ch RecordTimeStat: true, RecordScanStat: true, TaskId: worker.req.TaskID, - RequestSource: task.requestSource.GetRequestSource(), }) + req.InputRequestSource = task.requestSource.GetRequestSource() + if task.firstReadType != "" { + req.ReadType = task.firstReadType + req.IsRetryRequest = true + } if worker.req.ResourceGroupTagger != nil { worker.req.ResourceGroupTagger(req) } timeout := tikv.ReadTimeoutMedium - if task.tikvClientReadTimeout> 0 { + if task.tikvClientReadTimeout > 0 { timeout = time.Duration(task.tikvClientReadTimeout) * time.Millisecond } req.StoreTp = getEndPointType(task.storeType) @@ -1073,12 +1079,19 @@ func (worker *copIteratorWorker) handleTaskOnce(bo *Backoffer, task *copTask, ch tidbmetrics.DistSQLCoprRespBodySize.WithLabelValues(storeAddr).Observe(float64(len(copResp.Data))) } + var remains []*copTask if worker.req.Paging.Enable { - return worker.handleCopPagingResult(bo, rpcCtx, &copResponse{pbResp: copResp}, cacheKey, cacheValue, task, ch, costTime) + remains, err = worker.handleCopPagingResult(bo, rpcCtx, &copResponse{pbResp: copResp}, cacheKey, cacheValue, task, ch, costTime) + } else { + // Handles the response for non-paging copTask. + remains, err = worker.handleCopResponse(bo, rpcCtx, &copResponse{pbResp: copResp}, cacheKey, cacheValue, task, ch, nil, costTime) } - - // Handles the response for non-paging copTask. - return worker.handleCopResponse(bo, rpcCtx, &copResponse{pbResp: copResp}, cacheKey, cacheValue, task, ch, nil, costTime) + if req.ReadType != "" { + for _, remain := range remains { + remain.firstReadType = req.ReadType + } + } + return remains, err } const (