Skip to content

Commit

Permalink
planner: allow read from TiKV for sys schema when `tidb_isolation_r…
Browse files Browse the repository at this point in the history
…ead_engines` is set to tiflash (#51219)

close #51218
  • Loading branch information
YangKeao authored Feb 21, 2024
1 parent 2041d49 commit 72517a9
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/planner/core/planbuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -1236,7 +1236,7 @@ func getPossibleAccessPaths(ctx PlanContext, tableHints *hint.PlanHints, indexHi

func filterPathByIsolationRead(ctx PlanContext, paths []*util.AccessPath, tblName model.CIStr, dbName model.CIStr) ([]*util.AccessPath, error) {
// TODO: filter paths with isolation read locations.
if dbName.L == mysql.SystemDB {
if util2.IsSysDB(dbName.L) {
return paths, nil
}
isolationReadEngines := ctx.GetSessionVars().GetIsolationReadEngines()
Expand Down
9 changes: 9 additions & 0 deletions tests/integrationtest/r/planner/core/integration.result
Original file line number Diff line number Diff line change
Expand Up @@ -4352,3 +4352,12 @@ StreamAgg 1.00 root group by:planner__core__integration.sbtest.k, funcs:count(1
└─TableReader 1.00 root data:TableRangeScan
└─TableRangeScan 1.00 cop[tikv] table:sbtest range:[0,1), keep order:false, stats:pseudo
set @@tidb_opt_fix_control = default;
create table sys.t (id int);
insert into sys.t values (1),(2);
set tidb_isolation_read_engines='tiflash';
select * from sys.t;
id
1
2
drop table sys.t;
set tidb_isolation_read_engines=DEFAULT;
Expand Down
8 changes: 8 additions & 0 deletions tests/integrationtest/t/planner/core/integration.test
Original file line number Diff line number Diff line change
Expand Up @@ -2386,3 +2386,11 @@ set @@tidb_opt_fix_control = '46177:on';
explain format='brief' select row_number() over(order by a.k) from (select * from sbtest where id<10) a;
explain format='brief' select /*+ stream_agg() */ count(1) from sbtest where id<1 group by k;
set @@tidb_opt_fix_control = default;

# TestSysIsAccessibleWithTiFlashReadIsolation
create table sys.t (id int);
insert into sys.t values (1),(2);
set tidb_isolation_read_engines='tiflash';
select * from sys.t;
drop table sys.t;
set tidb_isolation_read_engines=DEFAULT;

0 comments on commit 72517a9

Please sign in to comment.