Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
Signed-off-by: yisaer <disxiaofei@163.com>
  • Loading branch information
Yisaer committed Nov 28, 2022
1 parent b8e5712 commit 89f9eaa
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
6 changes: 2 additions & 4 deletions planner/core/find_best_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -914,10 +914,8 @@ func (ds *DataSource) findBestTask(prop *property.PhysicalProperty, planCounter
}

// if the path is the point get range path with for update lock, we should forbid tiflash as it's store path.
if path.StoreType == kv.TiFlash && ds.isPointGetPath(path) {
if _, ok := ds.ctx.GetSessionVars().StmtCtx.LockTableIDs[ds.table.Meta().ID]; ok {
continue
}
if path.StoreType == kv.TiFlash && ds.isPointGetPath(path) && ds.isForUpdateRead {
continue
}

canConvertPointGet := len(path.Ranges) > 0 && path.StoreType == kv.TiKV && ds.isPointGetConvertableSchema()
Expand Down
9 changes: 6 additions & 3 deletions planner/core/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7555,16 +7555,19 @@ func TestEnableTiFlashReadForWriteStmt(t *testing.T) {
}

func TestPointGetWithSelectLock(t *testing.T) {
store := testkit.CreateMockStore(t)
store, dom := testkit.CreateMockStoreAndDomain(t)
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
tk.MustExec("create table t(a int, b int, c int, primary key(a, b));")
tk.MustExec("insert into t values(1,2,3), (4,5,6);")
tk.MustExec("alter table t set tiflash replica 1;")
tbl, err := dom.InfoSchema().TableByName(model.CIStr{O: "test", L: "test"}, model.CIStr{O: "t", L: "t"})
require.NoError(t, err)
// Set the hacked TiFlash replica for explain tests.
tbl.Meta().TiFlashReplica = &model.TiFlashReplicaInfo{Count: 1, Available: true}
tk.MustExec("set @@tidb_enable_tiflash_read_for_write_stmt = on;")
tk.MustExec("set @@tidb_isolation_read_engines='tidb,tiflash';")
tk.MustExec("begin;")
tk.MustGetErrMsg("explain select a, b from t where a = 1 and b = 2 for update;", "ERROR 1815 (HY000): Internal : Can't find a proper physical plan for this query")
tk.MustGetErrMsg("explain select a, b from t where a = 1 and b = 2 for update;", "[planner:1815]Internal : Can't find a proper physical plan for this query")
tk.MustQuery("explain select a, b from t where a = 1 for update;")
tk.MustExec("set tidb_isolation_read_engines='tidb,tikv,tiflash';")
tk.MustQuery("explain select a, b from t where a = 1 and b = 2 for update;")
Expand Down

0 comments on commit 89f9eaa

Please sign in to comment.