From f8119aa8ab76d6a59761ddcaa92282e312302190 Mon Sep 17 00:00:00 2001 From: you06 Date: Mon, 29 May 2023 18:30:41 +0800 Subject: [PATCH 1/3] This is an automated cherry-pick of #44240 Signed-off-by: ti-chi-bot Signed-off-by: you06 update go.mod Signed-off-by: you06 --- DEPS.bzl | 4 ++-- go.mod | 2 +- go.sum | 4 ++-- store/copr/coprocessor.go | 7 ++++++- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/DEPS.bzl b/DEPS.bzl index f7967d69bfef9..71cba1352fb6e 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:ymfnb0eVge07+Thoxrf/XwO6VR6TQYzBF4HwhBok1mA=", + version = "v2.0.8-0.20230704100033-56f822eb592f", ) go_repository( name = "com_github_tikv_pd", diff --git a/go.mod b/go.mod index 503e870797a57..e8d1a559f8c08 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.20230704100033-56f822eb592f 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..2f5ad0e82c8fa 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.20230704100033-56f822eb592f h1:ymfnb0eVge07+Thoxrf/XwO6VR6TQYzBF4HwhBok1mA= +github.com/tikv/client-go/v2 v2.0.8-0.20230704100033-56f822eb592f/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 } From 0c6dac31baf46fd75d253504476014e0e481ec12 Mon Sep 17 00:00:00 2001 From: you06 Date: Wed, 12 Jul 2023 12:40:37 +0800 Subject: [PATCH 2/3] update go.mod Signed-off-by: you06 --- DEPS.bzl | 4 ++-- go.mod | 2 +- go.sum | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/DEPS.bzl b/DEPS.bzl index 71cba1352fb6e..f97123bac5515 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:ymfnb0eVge07+Thoxrf/XwO6VR6TQYzBF4HwhBok1mA=", - version = "v2.0.8-0.20230704100033-56f822eb592f", + sum = "h1:bfFBJUTUcVvOp/1tJBXb6mFwvCXDS+FkKA2dfrdl/i4=", + version = "v2.0.8-0.20230712043820-61c30264fb17", ) go_repository( name = "com_github_tikv_pd", diff --git a/go.mod b/go.mod index e8d1a559f8c08..1282fc9c15a65 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.20230704100033-56f822eb592f + github.com/tikv/client-go/v2 v2.0.8-0.20230712043820-61c30264fb17 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 2f5ad0e82c8fa..2fa8e586dd03e 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.20230704100033-56f822eb592f h1:ymfnb0eVge07+Thoxrf/XwO6VR6TQYzBF4HwhBok1mA= -github.com/tikv/client-go/v2 v2.0.8-0.20230704100033-56f822eb592f/go.mod h1:bQtijg8EtFeW0VQGU3YCAkQlAQ6PL2UPWhr4Rm2ItDY= +github.com/tikv/client-go/v2 v2.0.8-0.20230712043820-61c30264fb17 h1:bfFBJUTUcVvOp/1tJBXb6mFwvCXDS+FkKA2dfrdl/i4= +github.com/tikv/client-go/v2 v2.0.8-0.20230712043820-61c30264fb17/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= From 4fbaabcb6271c31b1859b427ef9a1a531e1f7bbb Mon Sep 17 00:00:00 2001 From: you06 Date: Wed, 12 Jul 2023 14:59:51 +0800 Subject: [PATCH 3/3] update go.mod Signed-off-by: you06 --- DEPS.bzl | 4 ++-- go.mod | 2 +- go.sum | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/DEPS.bzl b/DEPS.bzl index f97123bac5515..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:bfFBJUTUcVvOp/1tJBXb6mFwvCXDS+FkKA2dfrdl/i4=", - version = "v2.0.8-0.20230712043820-61c30264fb17", + 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 1282fc9c15a65..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.20230712043820-61c30264fb17 + 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 2fa8e586dd03e..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.20230712043820-61c30264fb17 h1:bfFBJUTUcVvOp/1tJBXb6mFwvCXDS+FkKA2dfrdl/i4= -github.com/tikv/client-go/v2 v2.0.8-0.20230712043820-61c30264fb17/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=