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

*: update tikv/client-go to fix batch-client send loop panic issue #47716

Closed
wants to merge 7 commits into from
Closed
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
12 changes: 6 additions & 6 deletions DEPS.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -7067,13 +7067,13 @@ def go_deps():
name = "com_github_tikv_client_go_v2",
build_file_proto_mode = "disable_global",
importpath = "github.com/tikv/client-go/v2",
sha256 = "e4953948d2346bf26d95fcc860b612c7c1d86f07c80a754db2551067912d37c8",
strip_prefix = "github.com/tikv/client-go/v2@v2.0.8-0.20231010061802-07432ef6c031",
sha256 = "6ad31199d7498e5bd6e493790db713ee8b253276c116a414b25d67cf31e7fb5a",
strip_prefix = "github.com/tikv/client-go/v2@v2.0.8-0.20231017074406-2eaf68e0cd3d",
urls = [
"http://bazel-cache.pingcap.net:8080/gomod/github.com/tikv/client-go/v2/com_github_tikv_client_go_v2-v2.0.8-0.20231010061802-07432ef6c031.zip",
"http://ats.apps.svc/gomod/github.com/tikv/client-go/v2/com_github_tikv_client_go_v2-v2.0.8-0.20231010061802-07432ef6c031.zip",
"https://cache.hawkingrei.com/gomod/github.com/tikv/client-go/v2/com_github_tikv_client_go_v2-v2.0.8-0.20231010061802-07432ef6c031.zip",
"https://storage.googleapis.com/pingcapmirror/gomod/github.com/tikv/client-go/v2/com_github_tikv_client_go_v2-v2.0.8-0.20231010061802-07432ef6c031.zip",
"http://bazel-cache.pingcap.net:8080/gomod/github.com/tikv/client-go/v2/com_github_tikv_client_go_v2-v2.0.8-0.20231017074406-2eaf68e0cd3d.zip",
"http://ats.apps.svc/gomod/github.com/tikv/client-go/v2/com_github_tikv_client_go_v2-v2.0.8-0.20231017074406-2eaf68e0cd3d.zip",
"https://cache.hawkingrei.com/gomod/github.com/tikv/client-go/v2/com_github_tikv_client_go_v2-v2.0.8-0.20231017074406-2eaf68e0cd3d.zip",
"https://storage.googleapis.com/pingcapmirror/gomod/github.com/tikv/client-go/v2/com_github_tikv_client_go_v2-v2.0.8-0.20231017074406-2eaf68e0cd3d.zip",
],
)
go_repository(
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ require (
github.com/stretchr/testify v1.8.4
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.20231010061802-07432ef6c031
github.com/tikv/client-go/v2 v2.0.8-0.20231017074406-2eaf68e0cd3d
github.com/tikv/pd/client v0.0.0-20230912103610-2f57a9f050eb
github.com/timakin/bodyclose v0.0.0-20230421092635-574207250966
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 @@ -1027,8 +1027,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.20231010061802-07432ef6c031 h1:+D3p4UBbL1V3vCZ7FtaW9mZgeGq3U14+VfcHyiYn1mU=
github.com/tikv/client-go/v2 v2.0.8-0.20231010061802-07432ef6c031/go.mod h1:AjaU1PM3aVQih/zsYvc5sE9z7dAMxV+e881GNeZGTck=
github.com/tikv/client-go/v2 v2.0.8-0.20231017074406-2eaf68e0cd3d h1:PLGpRLh1E1zBdXNER52L5VCDCAuk8Bh1mowNvO1OUp4=
github.com/tikv/client-go/v2 v2.0.8-0.20231017074406-2eaf68e0cd3d/go.mod h1:AjaU1PM3aVQih/zsYvc5sE9z7dAMxV+e881GNeZGTck=
github.com/tikv/pd/client v0.0.0-20230912103610-2f57a9f050eb h1:hAcH9tFjQzQ3+ofrAHm4ajOTLliYCOfXpj3+boKOtac=
github.com/tikv/pd/client v0.0.0-20230912103610-2f57a9f050eb/go.mod h1:E+6qtPu8fJm5kNjvKWPVFqSgNAFPk07y2EjD03GWzuI=
github.com/timakin/bodyclose v0.0.0-20230421092635-574207250966 h1:quvGphlmUVU+nhpFa4gg4yJyTRJ13reZMDHrKwYw53M=
Expand Down
47 changes: 47 additions & 0 deletions tests/realtikvtest/sessiontest/session_fail_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@ package sessiontest
import (
"context"
"fmt"
"math/rand"
"strconv"
"sync"
"testing"
"time"

"github.com/pingcap/failpoint"
"github.com/pingcap/tidb/pkg/config"
Expand Down Expand Up @@ -317,3 +320,47 @@ func TestTiKVClientReadTimeout(t *testing.T) {
explain = fmt.Sprintf("%v", rows[0])
require.Regexp(t, ".*TableReader.* root time:.*, loops:.* cop_task: {num: 1, .* rpc_num: (3|4|5).*", explain)
}

func TestBatchClientDataRace(t *testing.T) {
// This test uses to detect data race, so it should run by `go test -race`.
if !*realtikvtest.WithRealTiKV {
t.Skip("skip test since it's only work for tikv")
}
config.UpdateGlobal(func(conf *config.Config) {
conf.TiKVClient.MaxBatchSize = 128
})
store := realtikvtest.CreateMockStoreAndSetup(t)
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
tk.MustExec("drop table if exists t")
tk.MustExec("create table if not exists t (a int primary key, b int)")

var wg sync.WaitGroup
for i := 0; i < 100; i++ {
wg.Add(1)
go func() {
defer wg.Done()
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
for j := 0; j < 100; j++ {
ctx, cancel := context.WithCancel(context.Background())
go func() {
// mock for kill query execution or timeout.
time.Sleep(time.Millisecond * time.Duration(rand.Intn(10)+1))
cancel()
}()
sqls := []string{
"select * from t where a = 1",
"select * from t where a in ( 1, 2, 3)",
"select * from t",
}
rs, _ := tk.ExecWithContext(ctx, sqls[j%len(sqls)])
if rs != nil {
session.ResultSetToStringSlice(ctx, tk.Session(), rs)
rs.Close()
}
}
}()
}
wg.Wait()
}