diff --git a/DEPS.bzl b/DEPS.bzl index f7967d69bfef9..ed0618a4b3be8 100644 --- a/DEPS.bzl +++ b/DEPS.bzl @@ -4171,8 +4171,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:7JvBwc+e1x4AXHtwXp9IK1X04Iokol+HgrWdukU5iqM=", - version = "v2.0.8-0.20230605085112-28247160f497", + sum = "h1:vgcLrfGffcHRPtgXWEeBgmnNcbz1t6XuYTPjPro35zQ=", + version = "v2.0.8-0.20230712065349-ef92db18a1dc", ) go_repository( name = "com_github_tikv_pd", diff --git a/go.mod b/go.mod index 503e870797a57..aa14368d21f41 100644 --- a/go.mod +++ b/go.mod @@ -94,7 +94,7 @@ require ( github.com/stretchr/testify v1.8.2 github.com/tdakkota/asciicheck v0.2.0 github.com/tiancaiamao/appdash v0.0.0-20181126055449-889f96f722a2 - github.com/tikv/client-go/v2 v2.0.8-0.20230605085112-28247160f497 + github.com/tikv/client-go/v2 v2.0.8-0.20230712065349-ef92db18a1dc github.com/tikv/pd/client v0.0.0-20230519121736-d15a686a670e github.com/timakin/bodyclose v0.0.0-20221125081123-e39cf3fc478e github.com/twmb/murmur3 v1.1.6 diff --git a/go.sum b/go.sum index ad89849dab581..deac32dcf50bb 100644 --- a/go.sum +++ b/go.sum @@ -963,8 +963,8 @@ github.com/tiancaiamao/appdash v0.0.0-20181126055449-889f96f722a2 h1:mbAskLJ0oJf github.com/tiancaiamao/appdash v0.0.0-20181126055449-889f96f722a2/go.mod h1:2PfKggNGDuadAa0LElHrByyrz4JPZ9fFx6Gs7nx7ZZU= github.com/tiancaiamao/gp v0.0.0-20221230034425-4025bc8a4d4a h1:J/YdBZ46WKpXsxsW93SG+q0F8KI+yFrcIDT4c/RNoc4= github.com/tiancaiamao/gp v0.0.0-20221230034425-4025bc8a4d4a/go.mod h1:h4xBhSNtOeEosLJ4P7JyKXX7Cabg7AVkWCK5gV2vOrM= -github.com/tikv/client-go/v2 v2.0.8-0.20230605085112-28247160f497 h1:7JvBwc+e1x4AXHtwXp9IK1X04Iokol+HgrWdukU5iqM= -github.com/tikv/client-go/v2 v2.0.8-0.20230605085112-28247160f497/go.mod h1:bQtijg8EtFeW0VQGU3YCAkQlAQ6PL2UPWhr4Rm2ItDY= +github.com/tikv/client-go/v2 v2.0.8-0.20230712065349-ef92db18a1dc h1:vgcLrfGffcHRPtgXWEeBgmnNcbz1t6XuYTPjPro35zQ= +github.com/tikv/client-go/v2 v2.0.8-0.20230712065349-ef92db18a1dc/go.mod h1:bQtijg8EtFeW0VQGU3YCAkQlAQ6PL2UPWhr4Rm2ItDY= github.com/tikv/pd/client v0.0.0-20230519121736-d15a686a670e h1:dO0YtekJ9IKiO9dXMZz0rNHPBiGCo+c37RUsnshoLwo= github.com/tikv/pd/client v0.0.0-20230519121736-d15a686a670e/go.mod h1:5vgcvO020ZCdMZkTrRdS/wFZQUab82BSfKE38T61ro0= github.com/timakin/bodyclose v0.0.0-20221125081123-e39cf3fc478e h1:MV6KaVu/hzByHP0UvJ4HcMGE/8a6A4Rggc/0wx2AvJo= diff --git a/store/copr/coprocessor.go b/store/copr/coprocessor.go index aa1329e89445d..f44ad273fd59e 100644 --- a/store/copr/coprocessor.go +++ b/store/copr/coprocessor.go @@ -265,6 +265,7 @@ type copTask struct { // we set this field to the target replica store ID and redirect the request to the replica. redirect2Replica *uint64 busyThreshold time.Duration + meetLockFallback bool } type batchedCopTask struct { @@ -1172,7 +1173,9 @@ func (worker *copIteratorWorker) handleTaskOnce(bo *Backoffer, task *copTask, ch // set ReadReplicaScope and TxnScope so that req.IsStaleRead will be true when it's a global scope stale read. req.ReadReplicaScope = worker.req.ReadReplicaScope req.TxnScope = worker.req.TxnScope - if worker.req.IsStaleness { + if task.meetLockFallback { + req.DisableStaleReadMeetLock() + } else if worker.req.IsStaleness { req.EnableStaleRead() } staleRead := req.GetStaleRead() @@ -1337,6 +1340,7 @@ func (worker *copIteratorWorker) handleCopResponse(bo *Backoffer, rpcCtx *tikv.R if err := worker.handleLockErr(bo, lockErr, task); err != nil { return nil, err } + task.meetLockFallback = true return worker.handleBatchRemainsOnErr(bo, rpcCtx, []*copTask{task}, resp.pbResp, task, ch) } if otherErr := resp.pbResp.GetOtherError(); otherErr != "" { @@ -1464,6 +1468,7 @@ func (worker *copIteratorWorker) handleBatchCopResponse(bo *Backoffer, rpcCtx *t if err := worker.handleLockErr(bo, resp.pbResp.GetLocked(), task); err != nil { return nil, err } + task.meetLockFallback = true appendRemainTasks(task) continue }