Skip to content

Commit

Permalink
fix bulid
Browse files Browse the repository at this point in the history
Signed-off-by: xufei <[email protected]>
  • Loading branch information
windtalker committed Jun 20, 2024
1 parent 3eac8d5 commit c4db947
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 18 deletions.
5 changes: 5 additions & 0 deletions pkg/executor/join/hash_join_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions pkg/executor/test/issuetest/executor_issue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand All @@ -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")
}
Expand Down Expand Up @@ -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")
Expand Down
28 changes: 14 additions & 14 deletions pkg/executor/test/jointest/hashjoin/hash_join_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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\")"))
Expand All @@ -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\")"))
Expand All @@ -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\")"))
Expand All @@ -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\")"))
Expand All @@ -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\")"))
Expand All @@ -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() {
Expand Down Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion pkg/executor/test/seqtest/seq_executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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]")
}
Expand Down

0 comments on commit c4db947

Please sign in to comment.