@ -44,10 +44,6 @@ var (
|
||||
enableHashJoinV2 = atomic.Bool{}
|
||||
)
|
||||
|
||||
func init() {
|
||||
enableHashJoinV2.Store(true)
|
||||
}
|
||||
|
||||
// IsHashJoinV2Enabled return true if hash join v2 is enabled
|
||||
func IsHashJoinV2Enabled() bool {
|
||||
// sizeOfUintptr should always equal to sizeOfUnsafePointer, because according to golang's doc,
|
||||
@ -869,12 +865,20 @@ func (*hashJoinRuntimeStatsV2) Tp() int {
|
||||
func (e *hashJoinRuntimeStatsV2) String() string {
|
||||
buf := bytes.NewBuffer(make([]byte, 0, 128))
|
||||
if e.fetchAndBuildHashTable > 0 {
|
||||
buf.WriteString("build_hash_table:{total:")
|
||||
buf.WriteString("build_hash_table:{concurrency:")
|
||||
buf.WriteString(strconv.Itoa(e.concurrent))
|
||||
buf.WriteString(", total:")
|
||||
buf.WriteString(execdetails.FormatDuration(e.fetchAndBuildHashTable))
|
||||
buf.WriteString(", fetch:")
|
||||
buf.WriteString(execdetails.FormatDuration(time.Duration(int64(e.fetchAndBuildHashTable) - e.maxBuildHashTable - e.maxPartitionData)))
|
||||
buf.WriteString(", partition:")
|
||||
buf.WriteString(execdetails.FormatDuration(time.Duration(e.partitionData)))
|
||||
buf.WriteString(", max partition:")
|
||||
buf.WriteString(execdetails.FormatDuration(time.Duration(e.maxPartitionData)))
|
||||
buf.WriteString(", build:")
|
||||
buf.WriteString(execdetails.FormatDuration(time.Duration(e.buildHashTable)))
|
||||
buf.WriteString(", max build:")
|
||||
buf.WriteString(execdetails.FormatDuration(time.Duration(e.maxBuildHashTable)))
|
||||
buf.WriteString("}")
|
||||
}
|
||||
if e.probe > 0 {
|
||||
|
||||
@ -178,9 +178,7 @@ func TestIssue30289(t *testing.T) {
|
||||
tk.MustExec("drop table if exists t")
|
||||
tk.MustExec("create table t(a int)")
|
||||
require.NoError(t, failpoint.Enable(fpName, `return(true)`))
|
||||
isHashJoinV2Enabled := join.IsHashJoinV2Enabled()
|
||||
defer func() {
|
||||
join.SetEnableHashJoinV2(isHashJoinV2Enabled)
|
||||
require.NoError(t, failpoint.Disable(fpName))
|
||||
}()
|
||||
useHashJoinV2 := []bool{true, false}
|
||||
@ -199,9 +197,7 @@ func TestIssue51998(t *testing.T) {
|
||||
tk.MustExec("drop table if exists t")
|
||||
tk.MustExec("create table t(a int)")
|
||||
require.NoError(t, failpoint.Enable(fpName, `return(true)`))
|
||||
isHashJoinV2Enabled := join.IsHashJoinV2Enabled()
|
||||
defer func() {
|
||||
join.SetEnableHashJoinV2(isHashJoinV2Enabled)
|
||||
require.NoError(t, failpoint.Disable(fpName))
|
||||
}()
|
||||
useHashJoinV2 := []bool{true, false}
|
||||
@ -621,8 +617,6 @@ func TestIssue42662(t *testing.T) {
|
||||
tk.MustExec("set global tidb_server_memory_limit='1600MB'")
|
||||
tk.MustExec("set global tidb_server_memory_limit_sess_min_size=128*1024*1024")
|
||||
tk.MustExec("set global tidb_mem_oom_action = 'cancel'")
|
||||
isHashJoinV2Enabled := join.IsHashJoinV2Enabled()
|
||||
defer join.SetEnableHashJoinV2(isHashJoinV2Enabled)
|
||||
useHashJoinV2 := []bool{true, false}
|
||||
for _, hashJoinV2 := range useHashJoinV2 {
|
||||
join.SetEnableHashJoinV2(hashJoinV2)
|
||||
|
||||
@ -411,9 +411,6 @@ func TestIssue20270(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)")
|
||||
enableHashJoinV2 := join.IsHashJoinV2Enabled()
|
||||
join.SetEnableHashJoinV2(false)
|
||||
defer join.SetEnableHashJoinV2(enableHashJoinV2)
|
||||
require.NoError(t, failpoint.Enable("github.com/pingcap/tidb/pkg/executor/join/killedInJoin2Chunk", "return(true)"))
|
||||
err := tk.QueryToErr("select /*+ HASH_JOIN(t, t1) */ * from t left join t1 on t.c1 = t1.c1 where t.c1 = 1 or t1.c2 > 20")
|
||||
require.Equal(t, exeerrors.ErrQueryInterrupted, err)
|
||||
@ -487,10 +484,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)")
|
||||
isHashJoinV2Enabled := join.IsHashJoinV2Enabled()
|
||||
join.SetEnableHashJoinV2(true)
|
||||
defer func() {
|
||||
join.SetEnableHashJoinV2(isHashJoinV2Enabled)
|
||||
join.SetEnableHashJoinV2(false)
|
||||
}()
|
||||
fpName := "github.com/pingcap/tidb/pkg/executor/join/finalizeCurrentSegPanic"
|
||||
require.NoError(t, failpoint.Enable(fpName, "panic(\"finalizeCurrentSegPanic\")"))
|
||||
@ -511,10 +507,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)")
|
||||
isHashJoinV2Enabled := join.IsHashJoinV2Enabled()
|
||||
join.SetEnableHashJoinV2(true)
|
||||
defer func() {
|
||||
join.SetEnableHashJoinV2(isHashJoinV2Enabled)
|
||||
join.SetEnableHashJoinV2(false)
|
||||
}()
|
||||
fpName := "github.com/pingcap/tidb/pkg/executor/join/splitPartitionPanic"
|
||||
require.NoError(t, failpoint.Enable(fpName, "panic(\"splitPartitionPanic\")"))
|
||||
@ -535,10 +530,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)")
|
||||
isHashJoinV2Enabled := join.IsHashJoinV2Enabled()
|
||||
join.SetEnableHashJoinV2(true)
|
||||
defer func() {
|
||||
join.SetEnableHashJoinV2(isHashJoinV2Enabled)
|
||||
join.SetEnableHashJoinV2(false)
|
||||
}()
|
||||
fpName := "github.com/pingcap/tidb/pkg/executor/join/processOneProbeChunkPanic"
|
||||
require.NoError(t, failpoint.Enable(fpName, "panic(\"processOneProbeChunkPanic\")"))
|
||||
@ -559,10 +553,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)")
|
||||
isHashJoinV2Enabled := join.IsHashJoinV2Enabled()
|
||||
join.SetEnableHashJoinV2(true)
|
||||
defer func() {
|
||||
join.SetEnableHashJoinV2(isHashJoinV2Enabled)
|
||||
join.SetEnableHashJoinV2(false)
|
||||
}()
|
||||
fpName := "github.com/pingcap/tidb/pkg/executor/join/createTasksPanic"
|
||||
require.NoError(t, failpoint.Enable(fpName, "panic(\"createTasksPanic\")"))
|
||||
@ -583,10 +576,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)")
|
||||
isHashJoinV2Enabled := join.IsHashJoinV2Enabled()
|
||||
join.SetEnableHashJoinV2(true)
|
||||
defer func() {
|
||||
join.SetEnableHashJoinV2(isHashJoinV2Enabled)
|
||||
join.SetEnableHashJoinV2(false)
|
||||
}()
|
||||
fpName := "github.com/pingcap/tidb/pkg/executor/join/buildHashTablePanic"
|
||||
require.NoError(t, failpoint.Enable(fpName, "panic(\"buildHashTablePanic\")"))
|
||||
@ -607,10 +599,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)")
|
||||
isHashJoinV2Enabled := join.IsHashJoinV2Enabled()
|
||||
join.SetEnableHashJoinV2(true)
|
||||
defer func() {
|
||||
join.SetEnableHashJoinV2(isHashJoinV2Enabled)
|
||||
join.SetEnableHashJoinV2(false)
|
||||
}()
|
||||
require.NoError(t, failpoint.Enable("github.com/pingcap/tidb/pkg/executor/join/killedDuringProbe", "return(true)"))
|
||||
defer func() {
|
||||
@ -641,10 +632,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)")
|
||||
isHashJoinV2Enabled := join.IsHashJoinV2Enabled()
|
||||
join.SetEnableHashJoinV2(true)
|
||||
defer func() {
|
||||
join.SetEnableHashJoinV2(isHashJoinV2Enabled)
|
||||
join.SetEnableHashJoinV2(false)
|
||||
}()
|
||||
require.NoError(t, failpoint.Enable("github.com/pingcap/tidb/pkg/executor/join/killedDuringBuild", "return(true)"))
|
||||
defer func() {
|
||||
|
||||
@ -1299,9 +1299,7 @@ func TestOOMPanicInHashJoinWhenFetchBuildRows(t *testing.T) {
|
||||
tk.MustExec("insert into t values(1,1),(2,2)")
|
||||
fpName := "github.com/pingcap/tidb/pkg/executor/join/errorFetchBuildSideRowsMockOOMPanic"
|
||||
require.NoError(t, failpoint.Enable(fpName, `panic("ERROR 1105 (HY000): Out Of Memory Quota![conn=1]")`))
|
||||
isHashJoinV2Enabled := join.IsHashJoinV2Enabled()
|
||||
defer func() {
|
||||
join.SetEnableHashJoinV2(isHashJoinV2Enabled)
|
||||
require.NoError(t, failpoint.Disable(fpName))
|
||||
}()
|
||||
useHashJoinV2 := []bool{true, false}
|
||||
|
||||
Reference in New Issue
Block a user