Skip to content

Commit

Permalink
planner: isolation read do not filter system tables (#17556) (#17719)
Browse files Browse the repository at this point in the history
Signed-off-by: sre-bot <sre-bot@pingcap.com>

Co-authored-by: Zhuomin(Charming) Liu <lzmhhh123@gmail.com>
  • Loading branch information
sre-bot and lzmhhh123 authored Jun 6, 2020
1 parent a0ad6f6 commit 203ec5a
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 1 deletion.
21 changes: 21 additions & 0 deletions planner/core/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,27 @@ func (s *testIntegrationSerialSuite) TestIsolationReadTiFlashUseIndexHint(c *C)
}
}

func (s *testIntegrationSerialSuite) TestIsolationReadDoNotFilterSystemDB(c *C) {
tk := testkit.NewTestKit(c, s.store)

tk.MustExec("use test")
tk.MustExec("set @@tidb_isolation_read_engines = \"tiflash\"")
var input []string
var output []struct {
SQL string
Plan []string
}
s.testData.GetTestCases(c, &input, &output)
for i, tt := range input {
s.testData.OnRecord(func() {
output[i].SQL = tt
output[i].Plan = s.testData.ConvertRowsToStrings(tk.MustQuery(tt).Rows())
})
res := tk.MustQuery(tt)
res.Check(testkit.Rows(output[i].Plan...))
}
}

func (s *testIntegrationSuite) TestPartitionTableStats(c *C) {
tk := testkit.NewTestKit(c, s.store)

Expand Down
2 changes: 1 addition & 1 deletion planner/core/planbuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -828,7 +828,7 @@ func (b *PlanBuilder) filterPathByIsolationRead(paths []*util.AccessPath, dbName
}
availableEngineStr += paths[i].StoreType.Name()
}
if _, ok := isolationReadEngines[paths[i].StoreType]; !ok {
if _, ok := isolationReadEngines[paths[i].StoreType]; !ok && paths[i].StoreType != kv.TiDB {
paths = append(paths[:i], paths[i+1:]...)
}
}
Expand Down
8 changes: 8 additions & 0 deletions planner/core/testdata/integration_serial_suite_in.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@
"desc select /*+ read_from_storage(tiflash[t]) */ avg(a) from t"
]
},
{
"name": "TestIsolationReadDoNotFilterSystemDB",
"cases": [
"desc select * from metrics_schema.tidb_query_duration where time >= '2019-12-23 16:10:13' and time <= '2019-12-23 16:30:13'",
"desc select * from information_schema.tables",
"desc select * from mysql.stats_meta"
]
},
{
"name": "TestIsolationReadTiFlashNotChoosePointGet",
"cases": [
Expand Down
24 changes: 24 additions & 0 deletions planner/core/testdata/integration_serial_suite_out.json
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,30 @@
}
]
},
{
"Name": "TestIsolationReadDoNotFilterSystemDB",
"Cases": [
{
"SQL": "desc select * from metrics_schema.tidb_query_duration where time >= '2019-12-23 16:10:13' and time <= '2019-12-23 16:30:13'",
"Plan": [
"MemTableScan_5 10000.00 root table:tidb_query_duration PromQL:histogram_quantile(0.9, sum(rate(tidb_server_handle_query_duration_seconds_bucket{}[60s])) by (le,sql_type,instance)), start_time:2019-12-23 16:10:13, end_time:2019-12-23 16:30:13, step:1m0s"
]
},
{
"SQL": "desc select * from information_schema.tables",
"Plan": [
"MemTableScan_4 10000.00 root table:TABLES "
]
},
{
"SQL": "desc select * from mysql.stats_meta",
"Plan": [
"TableReader_5 10000.00 root data:TableFullScan_4",
"└─TableFullScan_4 10000.00 cop[tikv] table:stats_meta keep order:false, stats:pseudo"
]
}
]
},
{
"Name": "TestIsolationReadTiFlashNotChoosePointGet",
"Cases": [
Expand Down

0 comments on commit 203ec5a

Please sign in to comment.