From c4db94772598c8e8c617e6cd29045d016ef8415a Mon Sep 17 00:00:00 2001 From: xufei Date: Tue, 18 Jun 2024 16:01:47 +0800 Subject: [PATCH] fix bulid Signed-off-by: xufei --- pkg/executor/join/hash_join_v2.go | 5 ++++ .../test/issuetest/executor_issue_test.go | 6 ++-- .../test/jointest/hashjoin/hash_join_test.go | 28 +++++++++---------- .../test/seqtest/seq_executor_test.go | 2 +- 4 files changed, 23 insertions(+), 18 deletions(-) diff --git a/pkg/executor/join/hash_join_v2.go b/pkg/executor/join/hash_join_v2.go index 17f0765777af5e..418247166051d9 100644 --- a/pkg/executor/join/hash_join_v2.go +++ b/pkg/executor/join/hash_join_v2.go @@ -51,6 +51,11 @@ func IsHashJoinV2Enabled() bool { return enableHashJoinV2.Load() && sizeOfUintptr >= sizeOfUnsafePointer } +// SetEnableHashJoinV2 enable/disable hash join v2 +func SetEnableHashJoinV2(enable bool) { + enableHashJoinV2.Store(enable) +} + type hashTableContext struct { // rowTables is used during split partition stage, each buildWorker has // its own rowTable diff --git a/pkg/executor/test/issuetest/executor_issue_test.go b/pkg/executor/test/issuetest/executor_issue_test.go index ed4edf43ba5bfc..e68c5fce4ba46c 100644 --- a/pkg/executor/test/issuetest/executor_issue_test.go +++ b/pkg/executor/test/issuetest/executor_issue_test.go @@ -183,7 +183,7 @@ func TestIssue30289(t *testing.T) { }() useHashJoinV2 := []bool{true, false} for _, hashJoinV2 := range useHashJoinV2 { - join.EnableHashJoinV2.Store(hashJoinV2) + join.SetEnableHashJoinV2(hashJoinV2) err := tk.QueryToErr("select /*+ hash_join(t1) */ * from t t1 join t t2 on t1.a=t2.a") require.EqualError(t, err, "issue30289 build return error") } @@ -202,7 +202,7 @@ func TestIssue51998(t *testing.T) { }() useHashJoinV2 := []bool{true, false} for _, hashJoinV2 := range useHashJoinV2 { - join.EnableHashJoinV2.Store(hashJoinV2) + join.SetEnableHashJoinV2(hashJoinV2) err := tk.QueryToErr("select /*+ hash_join(t1) */ * from t t1 join t t2 on t1.a=t2.a") require.EqualError(t, err, "issue51998 build return error") } @@ -619,7 +619,7 @@ func TestIssue42662(t *testing.T) { tk.MustExec("set global tidb_mem_oom_action = 'cancel'") useHashJoinV2 := []bool{true, false} for _, hashJoinV2 := range useHashJoinV2 { - join.EnableHashJoinV2.Store(hashJoinV2) + join.SetEnableHashJoinV2(hashJoinV2) require.NoError(t, failpoint.Enable("github.com/pingcap/tidb/pkg/executor/join/issue42662_1", `return(true)`)) // tk.Session() should be marked as MemoryTop1Tracker but not killed. tk.MustQuery("select /*+ hash_join(t1)*/ * from t1 join t2 on t1.a = t2.a and t1.b = t2.b") diff --git a/pkg/executor/test/jointest/hashjoin/hash_join_test.go b/pkg/executor/test/jointest/hashjoin/hash_join_test.go index 0bbea25bccc667..a52df40ec90428 100644 --- a/pkg/executor/test/jointest/hashjoin/hash_join_test.go +++ b/pkg/executor/test/jointest/hashjoin/hash_join_test.go @@ -489,9 +489,9 @@ func TestFinalizeCurrentSegPanic(t *testing.T) { tk.MustExec("create table t2 (a int, b int, c int)") tk.MustExec("insert into t1 values (1, 1, 1), (1, 2, 2), (2, 1, 3), (2, 2, 4)") tk.MustExec("insert into t2 values (1, 1, 1), (1, 2, 2), (2, 1, 3), (2, 2, 4)") - join.EnableHashJoinV2.Store(true) + join.SetEnableHashJoinV2(true) defer func() { - join.EnableHashJoinV2.Store(false) + join.SetEnableHashJoinV2(false) }() fpName := "github.com/pingcap/tidb/pkg/executor/join/finalizeCurrentSegPanic" require.NoError(t, failpoint.Enable(fpName, "panic(\"finalizeCurrentSegPanic\")")) @@ -512,9 +512,9 @@ func TestSplitPartitionPanic(t *testing.T) { tk.MustExec("create table t2 (a int, b int, c int)") tk.MustExec("insert into t1 values (1, 1, 1), (1, 2, 2), (2, 1, 3), (2, 2, 4)") tk.MustExec("insert into t2 values (1, 1, 1), (1, 2, 2), (2, 1, 3), (2, 2, 4)") - join.EnableHashJoinV2.Store(true) + join.SetEnableHashJoinV2(true) defer func() { - join.EnableHashJoinV2.Store(false) + join.SetEnableHashJoinV2(false) }() fpName := "github.com/pingcap/tidb/pkg/executor/join/splitPartitionPanic" require.NoError(t, failpoint.Enable(fpName, "panic(\"splitPartitionPanic\")")) @@ -535,9 +535,9 @@ func TestProcessOneProbeChunkPanic(t *testing.T) { tk.MustExec("create table t2 (a int, b int, c int)") tk.MustExec("insert into t1 values (1, 1, 1), (1, 2, 2), (2, 1, 3), (2, 2, 4)") tk.MustExec("insert into t2 values (1, 1, 1), (1, 2, 2), (2, 1, 3), (2, 2, 4)") - join.EnableHashJoinV2.Store(true) + join.SetEnableHashJoinV2(true) defer func() { - join.EnableHashJoinV2.Store(false) + join.SetEnableHashJoinV2(false) }() fpName := "github.com/pingcap/tidb/pkg/executor/join/processOneProbeChunkPanic" require.NoError(t, failpoint.Enable(fpName, "panic(\"processOneProbeChunkPanic\")")) @@ -558,9 +558,9 @@ func TestCreateTasksPanic(t *testing.T) { tk.MustExec("create table t2 (a int, b int, c int)") tk.MustExec("insert into t1 values (1, 1, 1), (1, 2, 2), (2, 1, 3), (2, 2, 4)") tk.MustExec("insert into t2 values (1, 1, 1), (1, 2, 2), (2, 1, 3), (2, 2, 4)") - join.EnableHashJoinV2.Store(true) + join.SetEnableHashJoinV2(true) defer func() { - join.EnableHashJoinV2.Store(false) + join.SetEnableHashJoinV2(false) }() fpName := "github.com/pingcap/tidb/pkg/executor/join/createTasksPanic" require.NoError(t, failpoint.Enable(fpName, "panic(\"createTasksPanic\")")) @@ -581,9 +581,9 @@ func TestBuildHashTablePanic(t *testing.T) { tk.MustExec("create table t2 (a int, b int, c int)") tk.MustExec("insert into t1 values (1, 1, 1), (1, 2, 2), (2, 1, 3), (2, 2, 4)") tk.MustExec("insert into t2 values (1, 1, 1), (1, 2, 2), (2, 1, 3), (2, 2, 4)") - join.EnableHashJoinV2.Store(true) + join.SetEnableHashJoinV2(true) defer func() { - join.EnableHashJoinV2.Store(false) + join.SetEnableHashJoinV2(false) }() fpName := "github.com/pingcap/tidb/pkg/executor/join/buildHashTablePanic" require.NoError(t, failpoint.Enable(fpName, "panic(\"buildHashTablePanic\")")) @@ -604,9 +604,9 @@ func TestKillDuringProbe(t *testing.T) { tk.MustExec("create table t1(c1 int, c2 int)") tk.MustExec("insert into t values(1,1),(2,2)") tk.MustExec("insert into t1 values(2,3),(4,4)") - join.EnableHashJoinV2.Store(true) + join.SetEnableHashJoinV2(true) defer func() { - join.EnableHashJoinV2.Store(false) + join.SetEnableHashJoinV2(false) }() require.NoError(t, failpoint.Enable("github.com/pingcap/tidb/pkg/executor/join/killedDuringProbe", "return(true)")) defer func() { @@ -637,9 +637,9 @@ func TestKillDuringBuild(t *testing.T) { tk.MustExec("create table t1(c1 int, c2 int)") tk.MustExec("insert into t values(1,1),(2,2)") tk.MustExec("insert into t1 values(2,3),(4,4)") - join.EnableHashJoinV2.Store(true) + join.SetEnableHashJoinV2(true) defer func() { - join.EnableHashJoinV2.Store(false) + join.SetEnableHashJoinV2(false) }() require.NoError(t, failpoint.Enable("github.com/pingcap/tidb/pkg/executor/join/killedDuringBuild", "return(true)")) defer func() { diff --git a/pkg/executor/test/seqtest/seq_executor_test.go b/pkg/executor/test/seqtest/seq_executor_test.go index 3a0fd3e62fa418..e6c509c2cae7c8 100644 --- a/pkg/executor/test/seqtest/seq_executor_test.go +++ b/pkg/executor/test/seqtest/seq_executor_test.go @@ -1304,7 +1304,7 @@ func TestOOMPanicInHashJoinWhenFetchBuildRows(t *testing.T) { }() useHashJoinV2 := []bool{true, false} for _, hashJoinV2 := range useHashJoinV2 { - join.EnableHashJoinV2.Store(hashJoinV2) + join.SetEnableHashJoinV2(hashJoinV2) err := tk.QueryToErr("select * from t as t2 join t as t1 where t1.c1=t2.c1") require.EqualError(t, err, "failpoint panic: ERROR 1105 (HY000): Out Of Memory Quota![conn=1]") }