Skip to content

Commit

Permalink
*: bump client-go with some regression tests (#57282) (#57765)
Browse files Browse the repository at this point in the history
ref #55287, close #56837, ref #57338, close #57425
  • Loading branch information
ti-chi-bot authored Dec 5, 2024
1 parent 1572a1a commit 4b4b177
Show file tree
Hide file tree
Showing 7 changed files with 97 additions and 11 deletions.
12 changes: 6 additions & 6 deletions DEPS.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -7041,13 +7041,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 = "00c96385cb29901a20d4da163038eb5f5e554fca2ec9775f2b87f56a79252d47",
strip_prefix = "github.com/tikv/client-go/v2@v2.0.8-0.20240920100427-3725b31fa3c0",
sha256 = "ec8fd9b0cdf1352758305c7bb2107d2d5a6782937853ecd2e76a561a4f054b40",
strip_prefix = "github.com/tikv/client-go/v2@v2.0.8-0.20241125064441-5ce6bf1f099c",
urls = [
"http://bazel-cache.pingcap.net:8080/gomod/github.com/tikv/client-go/v2/com_github_tikv_client_go_v2-v2.0.8-0.20240920100427-3725b31fa3c0.zip",
"http://ats.apps.svc/gomod/github.com/tikv/client-go/v2/com_github_tikv_client_go_v2-v2.0.8-0.20240920100427-3725b31fa3c0.zip",
"https://cache.hawkingrei.com/gomod/github.com/tikv/client-go/v2/com_github_tikv_client_go_v2-v2.0.8-0.20240920100427-3725b31fa3c0.zip",
"https://storage.googleapis.com/pingcapmirror/gomod/github.com/tikv/client-go/v2/com_github_tikv_client_go_v2-v2.0.8-0.20240920100427-3725b31fa3c0.zip",
"http://bazel-cache.pingcap.net:8080/gomod/github.com/tikv/client-go/v2/com_github_tikv_client_go_v2-v2.0.8-0.20241125064441-5ce6bf1f099c.zip",
"http://ats.apps.svc/gomod/github.com/tikv/client-go/v2/com_github_tikv_client_go_v2-v2.0.8-0.20241125064441-5ce6bf1f099c.zip",
"https://cache.hawkingrei.com/gomod/github.com/tikv/client-go/v2/com_github_tikv_client_go_v2-v2.0.8-0.20241125064441-5ce6bf1f099c.zip",
"https://storage.googleapis.com/pingcapmirror/gomod/github.com/tikv/client-go/v2/com_github_tikv_client_go_v2-v2.0.8-0.20241125064441-5ce6bf1f099c.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 @@ -104,7 +104,7 @@ require (
github.com/stretchr/testify v1.9.0
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.20240920100427-3725b31fa3c0
github.com/tikv/client-go/v2 v2.0.8-0.20241125064441-5ce6bf1f099c
github.com/tikv/pd/client v0.0.0-20240724132535-fcb34c90790c
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 @@ -997,8 +997,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.20240920100427-3725b31fa3c0 h1:fRrgcL5JMtirxL+gp2/+pB6x1CkAb3kbaI7lnQU7NGI=
github.com/tikv/client-go/v2 v2.0.8-0.20240920100427-3725b31fa3c0/go.mod h1:37p0ryKaieJbBpVDWnaPi2ZS6UFqkgpsemBLkGX2FvM=
github.com/tikv/client-go/v2 v2.0.8-0.20241125064441-5ce6bf1f099c h1:c5/4ODu6lcuueN7lUtIyHrGeWLCHVZpAbrfFoNfP+UI=
github.com/tikv/client-go/v2 v2.0.8-0.20241125064441-5ce6bf1f099c/go.mod h1:37p0ryKaieJbBpVDWnaPi2ZS6UFqkgpsemBLkGX2FvM=
github.com/tikv/pd/client v0.0.0-20240724132535-fcb34c90790c h1:oZygf/SCdTUhjoHuZRE85EBgK0oA6LjikpWuJqqjM8U=
github.com/tikv/pd/client v0.0.0-20240724132535-fcb34c90790c/go.mod h1:NW6Af689Jw1FDxjq+WL0nqOdmQ1XT0ly2R1SIKfQuUw=
github.com/timakin/bodyclose v0.0.0-20230421092635-574207250966 h1:quvGphlmUVU+nhpFa4gg4yJyTRJ13reZMDHrKwYw53M=
Expand Down
2 changes: 1 addition & 1 deletion pkg/executor/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@ func (a *ExecStmt) handleStmtForeignKeyTrigger(ctx context.Context, e exec.Execu
if stmtCtx.ForeignKeyTriggerCtx.HasFKCascades {
// If the ExecStmt has foreign key cascade to be executed, we need call `StmtCommit` to commit the ExecStmt itself
// change first.
// Since `UnionScanExec` use `SnapshotIter` and `SnapshotGetter` to read txn mem-buffer, if we don't do `StmtCommit`,
// Since `UnionScanExec` use `SnapshotIter` and `SnapshotGetter` to read txn mem-buffer, if we don't do `StmtCommit`,
// then the fk cascade executor can't read the mem-buffer changed by the ExecStmt.
a.Ctx.StmtCommit(ctx)
}
Expand Down
15 changes: 15 additions & 0 deletions pkg/executor/union_scan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,21 @@ func TestIssue32422(t *testing.T) {
tk.MustExec("rollback")
}

func TestSnapshotWithConcurrentWrite(t *testing.T) {
store := testkit.CreateMockStore(t)
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
tk.MustExec("create table t1 (id int auto_increment key, b int, index(b));")

tk.MustExec("begin")
tk.MustExec("insert into t1 (b) values (1),(2),(3),(4),(5),(6),(7),(8);")
for j := 0; j < 16; j++ {
tk.MustExec("insert into t1 (b) select /*+ use_index(t1, b) */ id from t1;")
}
tk.MustQuery("select count(1) from t1").Check(testkit.Rows("524288")) // 8 * 2^16 rows
tk.MustExec("rollback")
}

func BenchmarkUnionScanRead(b *testing.B) {
store := testkit.CreateMockStore(b)

Expand Down
2 changes: 1 addition & 1 deletion pkg/session/test/txn/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ go_test(
],
flaky = True,
race = "on",
shard_count = 11,
shard_count = 13,
deps = [
"//pkg/config",
"//pkg/kv",
Expand Down
71 changes: 71 additions & 0 deletions pkg/session/test/txn/txn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -629,3 +629,74 @@ func TestCommitRetryCount(t *testing.T) {
// No auto retry because retry limit is set to 0.
require.Error(t, tk1.ExecToErr("commit"))
}

func TestMemBufferSnapshotRead(t *testing.T) {
store := testkit.CreateMockStore(t)

tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")

tk.MustExec("drop table if exists t;")
tk.MustExec("create table t(a int primary key, b int, index i(b));")

tk.MustExec("set session tidb_distsql_scan_concurrency = 1;")
tk.MustExec("set session tidb_index_lookup_join_concurrency = 1;")
tk.MustExec("set session tidb_projection_concurrency=1;")
tk.MustExec("set session tidb_init_chunk_size=1;")
tk.MustExec("set session tidb_max_chunk_size=40;")
tk.MustExec("set session tidb_index_join_batch_size = 10")

tk.MustExec("begin;")
// write (0, 0), (1, 1), ... ,(100, 100) into membuffer
var sb strings.Builder
sb.WriteString("insert into t values ")
for i := 0; i <= 100; i++ {
if i > 0 {
sb.WriteString(", ")
}
sb.WriteString(fmt.Sprintf("(%d, %d)", i, i))
}
tk.MustExec(sb.String())

// insert on duplicate key statement should update the table to (0, 100), (1, 99), ... (100, 0)
// This statement will create UnionScan dynamically during execution, and some UnionScan will see staging data(should be bypassed),
// so it relies on correct snapshot read to get the expected result.
tk.MustExec("insert into t (select /*+ INL_JOIN(t1) */ 100 - t1.a as a, t1.b from t t1, (select a, b from t) t2 where t1.b = t2.b) on duplicate key update b = values(b)")

require.Empty(t, tk.MustQuery("select a, b from t where a + b != 100;").Rows())
tk.MustExec("commit;")
require.Empty(t, tk.MustQuery("select a, b from t where a + b != 100;").Rows())

tk.MustExec("set session tidb_distsql_scan_concurrency = default;")
tk.MustExec("set session tidb_index_lookup_join_concurrency = default;")
tk.MustExec("set session tidb_projection_concurrency=default;")
tk.MustExec("set session tidb_init_chunk_size=default;")
tk.MustExec("set session tidb_max_chunk_size=default;")
tk.MustExec("set session tidb_index_join_batch_size = default")
}

func TestMemBufferCleanupMemoryLeak(t *testing.T) {
// Test if cleanup memory will cause a memory leak.
// When an in-txn statement fails, TiDB cleans up the mutations from this statement.
// If there's a memory leak, the memory usage could increase uncontrollably with retries.
store := testkit.CreateMockStore(t)
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
tk.MustExec("create table t(a varchar(255) primary key)")
key1 := strings.Repeat("a", 255)
key2 := strings.Repeat("b", 255)
tk.MustExec(`set global tidb_mem_oom_action='cancel'`)
tk.MustExec("set session tidb_mem_quota_query=10240")
tk.MustExec("begin")
tk.MustExec("insert into t values(?)", key2)
for i := 0; i < 100; i++ {
// The insert statement will fail because of the duplicate key error.
err := tk.ExecToErr("insert into t values(?), (?)", key1, key2)
require.Error(t, err)
if strings.Contains(err.Error(), "Duplicate") {
continue
}
require.NoError(t, err)
}
tk.MustExec("commit")
}

0 comments on commit 4b4b177

Please sign in to comment.