-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
planner: add more test cases about tiflash and dynamic mode #25111
Merged
+138
−0
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
74f22ad
add more test cases about tiflash and dynamic mode
qw4990 bc9d833
Update executor/tiflash_test.go
qw4990 5e32ff8
fixup
qw4990 b18d37d
Merge branch 'master' into dynamicmode-tiflash
qw4990 51bb553
Merge branch 'master' into dynamicmode-tiflash
ti-chi-bot 23f2df7
Merge branch 'master' into dynamicmode-tiflash
ti-chi-bot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,8 @@ package executor_test | |
|
||
import ( | ||
"fmt" | ||
"math/rand" | ||
"strings" | ||
"sync" | ||
"sync/atomic" | ||
"time" | ||
|
@@ -248,6 +250,142 @@ func (s *tiflashTestSuite) TestInjectExtraProj(c *C) { | |
tk.MustQuery("select avg(a), a from t group by a").Check(testkit.Rows("9223372036854775807.0000 9223372036854775807")) | ||
} | ||
|
||
func (s *tiflashTestSuite) TestTiFlashPartitionTableShuffledHashJoin(c *C) { | ||
if israce.RaceEnabled { | ||
c.Skip("exhaustive types test, skip race test") | ||
} | ||
|
||
tk := testkit.NewTestKit(c, s.store) | ||
tk.MustExec(`create database tiflash_partition_SHJ`) | ||
tk.MustExec("use tiflash_partition_SHJ") | ||
tk.MustExec(`create table thash (a int, b int) partition by hash(a) partitions 4`) | ||
tk.MustExec(`create table trange (a int, b int) partition by range(a) ( | ||
partition p0 values less than (100), partition p1 values less than (200), | ||
partition p2 values less than (300), partition p3 values less than (400))`) | ||
listPartitions := make([]string, 4) | ||
for i := 0; i < 400; i++ { | ||
idx := i % 4 | ||
if listPartitions[idx] != "" { | ||
listPartitions[idx] += ", " | ||
} | ||
listPartitions[idx] = listPartitions[idx] + fmt.Sprintf("%v", i) | ||
} | ||
tk.MustExec(`create table tlist (a int, b int) partition by list(a) ( | ||
partition p0 values in (` + listPartitions[0] + `), partition p1 values in (` + listPartitions[1] + `), | ||
partition p2 values in (` + listPartitions[2] + `), partition p3 values in (` + listPartitions[3] + `))`) | ||
tk.MustExec(`create table tnormal (a int, b int)`) | ||
|
||
for _, tbl := range []string{`thash`, `trange`, `tlist`, `tnormal`} { | ||
tk.MustExec("alter table " + tbl + " set tiflash replica 1") | ||
tb := testGetTableByName(c, tk.Se, "tiflash_partition_SHJ", tbl) | ||
err := domain.GetDomain(tk.Se).DDL().UpdateTableReplicaInfo(tk.Se, tb.Meta().ID, true) | ||
c.Assert(err, IsNil) | ||
} | ||
|
||
vals := make([]string, 0, 100) | ||
for i := 0; i < 100; i++ { | ||
vals = append(vals, fmt.Sprintf("(%v, %v)", rand.Intn(400), rand.Intn(400))) | ||
} | ||
for _, tbl := range []string{`thash`, `trange`, `tlist`, `tnormal`} { | ||
tk.MustExec(fmt.Sprintf("insert into %v values %v", tbl, strings.Join(vals, ", "))) | ||
tk.MustExec(fmt.Sprintf("analyze table %v", tbl)) | ||
} | ||
|
||
tk.MustExec("SET tidb_allow_mpp=2") | ||
tk.MustExec("SET tidb_opt_broadcast_join=0") | ||
tk.MustExec("SET tidb_broadcast_join_threshold_count=0") | ||
tk.MustExec("SET tidb_broadcast_join_threshold_size=0") | ||
tk.MustExec("set @@session.tidb_isolation_read_engines='tiflash'") | ||
|
||
lr := func() (int, int) { | ||
l, r := rand.Intn(400), rand.Intn(400) | ||
if l > r { | ||
l, r = r, l | ||
} | ||
return l, r | ||
} | ||
for i := 0; i < 2; i++ { | ||
l1, r1 := lr() | ||
l2, r2 := lr() | ||
cond := fmt.Sprintf("t1.b>=%v and t1.b<=%v and t2.b>=%v and t2.b<=%v", l1, r1, l2, r2) | ||
var res [][]interface{} | ||
for _, mode := range []string{"static", "dynamic"} { | ||
tk.MustExec(fmt.Sprintf("set @@tidb_partition_prune_mode = '%v'", mode)) | ||
for _, tbl := range []string{`thash`, `trange`, `tlist`, `tnormal`} { | ||
q := fmt.Sprintf("select count(*) from %v t1 join %v t2 on t1.a=t2.a where %v", tbl, tbl, cond) | ||
if res == nil { | ||
res = tk.MustQuery(q).Sort().Rows() | ||
} else { | ||
tk.MustQuery(q).Check(res) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
func (s *tiflashTestSuite) TestTiFlashPartitionTableReader(c *C) { | ||
if israce.RaceEnabled { | ||
c.Skip("exhaustive types test, skip race test") | ||
} | ||
|
||
tk := testkit.NewTestKit(c, s.store) | ||
tk.MustExec(`create database tiflash_partition_tablereader`) | ||
tk.MustExec("use tiflash_partition_tablereader") | ||
tk.MustExec(`create table thash (a int, b int) partition by hash(a) partitions 4`) | ||
tk.MustExec(`create table trange (a int, b int) partition by range(a) ( | ||
partition p0 values less than (100), partition p1 values less than (200), | ||
partition p2 values less than (300), partition p3 values less than (400))`) | ||
listPartitions := make([]string, 4) | ||
for i := 0; i < 400; i++ { | ||
idx := i % 4 | ||
if listPartitions[idx] != "" { | ||
listPartitions[idx] += ", " | ||
} | ||
listPartitions[idx] = listPartitions[idx] + fmt.Sprintf("%v", i) | ||
} | ||
tk.MustExec(`create table tlist (a int, b int) partition by list(a) ( | ||
partition p0 values in (` + listPartitions[0] + `), partition p1 values in (` + listPartitions[1] + `), | ||
partition p2 values in (` + listPartitions[2] + `), partition p3 values in (` + listPartitions[3] + `))`) | ||
tk.MustExec(`create table tnormal (a int, b int)`) | ||
|
||
for _, tbl := range []string{`thash`, `trange`, `tlist`, `tnormal`} { | ||
tk.MustExec("alter table " + tbl + " set tiflash replica 1") | ||
tb := testGetTableByName(c, tk.Se, "tiflash_partition_tablereader", tbl) | ||
err := domain.GetDomain(tk.Se).DDL().UpdateTableReplicaInfo(tk.Se, tb.Meta().ID, true) | ||
c.Assert(err, IsNil) | ||
} | ||
|
||
vals := make([]string, 0, 500) | ||
for i := 0; i < 500; i++ { | ||
vals = append(vals, fmt.Sprintf("(%v, %v)", rand.Intn(400), rand.Intn(400))) | ||
} | ||
for _, tbl := range []string{`thash`, `trange`, `tlist`, `tnormal`} { | ||
tk.MustExec(fmt.Sprintf("insert into %v values %v", tbl, strings.Join(vals, ", "))) | ||
} | ||
|
||
tk.MustExec("SET tidb_allow_mpp=2") | ||
tk.MustExec("set @@session.tidb_isolation_read_engines='tiflash'") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto. |
||
for i := 0; i < 100; i++ { | ||
l, r := rand.Intn(400), rand.Intn(400) | ||
if l > r { | ||
l, r = r, l | ||
} | ||
cond := fmt.Sprintf("a>=%v and a<=%v", l, r) | ||
var res [][]interface{} | ||
for _, mode := range []string{"static", "dynamic"} { | ||
tk.MustExec(fmt.Sprintf("set @@tidb_partition_prune_mode = '%v'", mode)) | ||
for _, tbl := range []string{"thash", "trange", "tlist", "tnormal"} { | ||
q := fmt.Sprintf("select * from %v where %v", tbl, cond) | ||
if res == nil { | ||
res = tk.MustQuery(q).Sort().Rows() | ||
} else { | ||
tk.MustQuery(q).Sort().Check(res) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
func (s *tiflashTestSuite) TestPartitionTable(c *C) { | ||
tk := testkit.NewTestKit(c, s.store) | ||
tk.MustExec("use test") | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shall we check failpoint or use tidb_allow_mpp=2 to make sure we use mpp?