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

*: bump client-go with some regression tests (#57282) #57763

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 @@ -3603,8 +3603,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:lKLA4jW6wj/A15+sb901WXvGd4xvdGuGDOndtyVTV/8=",
version = "v2.0.4-0.20240910032334-87841020c53e",
sum = "h1:0YcirnuxtXC9eQRb231im1M5w/n7JFuOo0IgE/K9ffM=",
version = "v2.0.4-0.20241125064444-5f59e4e34c62",
)
go_repository(
name = "com_github_tikv_pd_client",
Expand Down
2 changes: 1 addition & 1 deletion executor/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ func (a *ExecStmt) handleStmtForeignKeyTrigger(ctx context.Context, e Executor)
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()
}
Expand Down
15 changes: 15 additions & 0 deletions executor/union_scan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,21 @@ func TestIssue36903(t *testing.T) {
tk.MustQuery("select pkey from t_vwvgdc where 0 <> 0 union select pkey from t_vwvgdc;").Sort().Check(testkit.Rows("15000", "228000"))
}

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 go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ require (
github.com/stretchr/testify v1.8.4
github.com/tdakkota/asciicheck v0.1.1
github.com/tiancaiamao/appdash v0.0.0-20181126055449-889f96f722a2
github.com/tikv/client-go/v2 v2.0.4-0.20240910032334-87841020c53e
github.com/tikv/client-go/v2 v2.0.4-0.20241125064444-5f59e4e34c62
github.com/tikv/pd/client v0.0.0-20230904040343-947701a32c05
github.com/timakin/bodyclose v0.0.0-20210704033933-f49887972144
github.com/twmb/murmur3 v1.1.3
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -948,8 +948,8 @@ github.com/tenntenn/text/transform v0.0.0-20200319021203-7eef512accb3 h1:f+jULpR
github.com/tenntenn/text/transform v0.0.0-20200319021203-7eef512accb3/go.mod h1:ON8b8w4BN/kE1EOhwT0o+d62W65a6aPw1nouo9LMgyY=
github.com/tiancaiamao/appdash v0.0.0-20181126055449-889f96f722a2 h1:mbAskLJ0oJfDRtkanvQPiooDH8HvJ2FBh+iKT/OmiQQ=
github.com/tiancaiamao/appdash v0.0.0-20181126055449-889f96f722a2/go.mod h1:2PfKggNGDuadAa0LElHrByyrz4JPZ9fFx6Gs7nx7ZZU=
github.com/tikv/client-go/v2 v2.0.4-0.20240910032334-87841020c53e h1:lKLA4jW6wj/A15+sb901WXvGd4xvdGuGDOndtyVTV/8=
github.com/tikv/client-go/v2 v2.0.4-0.20240910032334-87841020c53e/go.mod h1:mmVCLP2OqWvQJPOIevQPZvGphzh/oq9vv8J5LDfpadQ=
github.com/tikv/client-go/v2 v2.0.4-0.20241125064444-5f59e4e34c62 h1:0YcirnuxtXC9eQRb231im1M5w/n7JFuOo0IgE/K9ffM=
github.com/tikv/client-go/v2 v2.0.4-0.20241125064444-5f59e4e34c62/go.mod h1:mmVCLP2OqWvQJPOIevQPZvGphzh/oq9vv8J5LDfpadQ=
github.com/tikv/pd/client v0.0.0-20230904040343-947701a32c05 h1:e4hLUKfgfPeJPZwOfU+/I/03G0sn6IZqVcbX/5o+hvM=
github.com/tikv/pd/client v0.0.0-20230904040343-947701a32c05/go.mod h1:MLIl+d2WbOF4A3U88WKtyXrQQW417wZDDvBcq2IW9bQ=
github.com/timakin/bodyclose v0.0.0-20210704033933-f49887972144 h1:kl4KhGNsJIbDHS9/4U9yQo1UcPQM0kOMJHn29EoH/Ro=
Expand Down
26 changes: 26 additions & 0 deletions session/session_test/session_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4259,3 +4259,29 @@ func TestMemBufferSnapshotRead(t *testing.T) {
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")
}
Loading