Skip to content

Commit 858ba74

Browse files
authored
*: bump client-go with some regression tests (#57282) (#57763)
ref #55287, close #56837, ref #57338, close #57425
1 parent d7b3aae commit 858ba74

File tree

6 files changed

+47
-6
lines changed

6 files changed

+47
-6
lines changed

DEPS.bzl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3603,8 +3603,8 @@ def go_deps():
36033603
name = "com_github_tikv_client_go_v2",
36043604
build_file_proto_mode = "disable_global",
36053605
importpath = "github.com/tikv/client-go/v2",
3606-
sum = "h1:lKLA4jW6wj/A15+sb901WXvGd4xvdGuGDOndtyVTV/8=",
3607-
version = "v2.0.4-0.20240910032334-87841020c53e",
3606+
sum = "h1:0YcirnuxtXC9eQRb231im1M5w/n7JFuOo0IgE/K9ffM=",
3607+
version = "v2.0.4-0.20241125064444-5f59e4e34c62",
36083608
)
36093609
go_repository(
36103610
name = "com_github_tikv_pd_client",

executor/adapter.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,7 @@ func (a *ExecStmt) handleStmtForeignKeyTrigger(ctx context.Context, e Executor)
593593
if stmtCtx.ForeignKeyTriggerCtx.HasFKCascades {
594594
// If the ExecStmt has foreign key cascade to be executed, we need call `StmtCommit` to commit the ExecStmt itself
595595
// change first.
596-
// Since `UnionScanExec` use `SnapshotIter` and `SnapshotGetter` to read txn mem-buffer, if we don't do `StmtCommit`,
596+
// Since `UnionScanExec` use `SnapshotIter` and `SnapshotGetter` to read txn mem-buffer, if we don't do `StmtCommit`,
597597
// then the fk cascade executor can't read the mem-buffer changed by the ExecStmt.
598598
a.Ctx.StmtCommit()
599599
}

executor/union_scan_test.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -595,6 +595,21 @@ func TestIssue36903(t *testing.T) {
595595
tk.MustQuery("select pkey from t_vwvgdc where 0 <> 0 union select pkey from t_vwvgdc;").Sort().Check(testkit.Rows("15000", "228000"))
596596
}
597597

598+
func TestSnapshotWithConcurrentWrite(t *testing.T) {
599+
store := testkit.CreateMockStore(t)
600+
tk := testkit.NewTestKit(t, store)
601+
tk.MustExec("use test")
602+
tk.MustExec("create table t1 (id int auto_increment key, b int, index(b));")
603+
604+
tk.MustExec("begin")
605+
tk.MustExec("insert into t1 (b) values (1),(2),(3),(4),(5),(6),(7),(8);")
606+
for j := 0; j < 16; j++ {
607+
tk.MustExec("insert into t1 (b) select /*+ use_index(t1, b) */ id from t1;")
608+
}
609+
tk.MustQuery("select count(1) from t1").Check(testkit.Rows("524288")) // 8 * 2^16 rows
610+
tk.MustExec("rollback")
611+
}
612+
598613
func BenchmarkUnionScanRead(b *testing.B) {
599614
store := testkit.CreateMockStore(b)
600615

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ require (
9090
github.com/stretchr/testify v1.8.4
9191
github.com/tdakkota/asciicheck v0.1.1
9292
github.com/tiancaiamao/appdash v0.0.0-20181126055449-889f96f722a2
93-
github.com/tikv/client-go/v2 v2.0.4-0.20240910032334-87841020c53e
93+
github.com/tikv/client-go/v2 v2.0.4-0.20241125064444-5f59e4e34c62
9494
github.com/tikv/pd/client v0.0.0-20230904040343-947701a32c05
9595
github.com/timakin/bodyclose v0.0.0-20210704033933-f49887972144
9696
github.com/twmb/murmur3 v1.1.3

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -948,8 +948,8 @@ github.com/tenntenn/text/transform v0.0.0-20200319021203-7eef512accb3 h1:f+jULpR
948948
github.com/tenntenn/text/transform v0.0.0-20200319021203-7eef512accb3/go.mod h1:ON8b8w4BN/kE1EOhwT0o+d62W65a6aPw1nouo9LMgyY=
949949
github.com/tiancaiamao/appdash v0.0.0-20181126055449-889f96f722a2 h1:mbAskLJ0oJfDRtkanvQPiooDH8HvJ2FBh+iKT/OmiQQ=
950950
github.com/tiancaiamao/appdash v0.0.0-20181126055449-889f96f722a2/go.mod h1:2PfKggNGDuadAa0LElHrByyrz4JPZ9fFx6Gs7nx7ZZU=
951-
github.com/tikv/client-go/v2 v2.0.4-0.20240910032334-87841020c53e h1:lKLA4jW6wj/A15+sb901WXvGd4xvdGuGDOndtyVTV/8=
952-
github.com/tikv/client-go/v2 v2.0.4-0.20240910032334-87841020c53e/go.mod h1:mmVCLP2OqWvQJPOIevQPZvGphzh/oq9vv8J5LDfpadQ=
951+
github.com/tikv/client-go/v2 v2.0.4-0.20241125064444-5f59e4e34c62 h1:0YcirnuxtXC9eQRb231im1M5w/n7JFuOo0IgE/K9ffM=
952+
github.com/tikv/client-go/v2 v2.0.4-0.20241125064444-5f59e4e34c62/go.mod h1:mmVCLP2OqWvQJPOIevQPZvGphzh/oq9vv8J5LDfpadQ=
953953
github.com/tikv/pd/client v0.0.0-20230904040343-947701a32c05 h1:e4hLUKfgfPeJPZwOfU+/I/03G0sn6IZqVcbX/5o+hvM=
954954
github.com/tikv/pd/client v0.0.0-20230904040343-947701a32c05/go.mod h1:MLIl+d2WbOF4A3U88WKtyXrQQW417wZDDvBcq2IW9bQ=
955955
github.com/timakin/bodyclose v0.0.0-20210704033933-f49887972144 h1:kl4KhGNsJIbDHS9/4U9yQo1UcPQM0kOMJHn29EoH/Ro=

session/session_test/session_test.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4259,3 +4259,29 @@ func TestMemBufferSnapshotRead(t *testing.T) {
42594259
tk.MustExec("set session tidb_max_chunk_size=default;")
42604260
tk.MustExec("set session tidb_index_join_batch_size = default")
42614261
}
4262+
4263+
func TestMemBufferCleanupMemoryLeak(t *testing.T) {
4264+
// Test if cleanup memory will cause a memory leak.
4265+
// When an in-txn statement fails, TiDB cleans up the mutations from this statement.
4266+
// If there's a memory leak, the memory usage could increase uncontrollably with retries.
4267+
store := testkit.CreateMockStore(t)
4268+
tk := testkit.NewTestKit(t, store)
4269+
tk.MustExec("use test")
4270+
tk.MustExec("create table t(a varchar(255) primary key)")
4271+
key1 := strings.Repeat("a", 255)
4272+
key2 := strings.Repeat("b", 255)
4273+
tk.MustExec(`set global tidb_mem_oom_action='cancel'`)
4274+
tk.MustExec("set session tidb_mem_quota_query=10240")
4275+
tk.MustExec("begin")
4276+
tk.MustExec("insert into t values(?)", key2)
4277+
for i := 0; i < 100; i++ {
4278+
// The insert statement will fail because of the duplicate key error.
4279+
err := tk.ExecToErr("insert into t values(?), (?)", key1, key2)
4280+
require.Error(t, err)
4281+
if strings.Contains(err.Error(), "Duplicate") {
4282+
continue
4283+
}
4284+
require.NoError(t, err)
4285+
}
4286+
tk.MustExec("commit")
4287+
}

0 commit comments

Comments
 (0)