Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

store/copr: disable stale read when meeting lock for cop (#44240) #44253

Merged
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
4 changes: 2 additions & 2 deletions DEPS.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
7 changes: 6 additions & 1 deletion store/copr/coprocessor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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 != "" {
Expand Down Expand Up @@ -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
}
Expand Down