From 941cbe33f87ec92c6edfe285ecb97886834c9ecf Mon Sep 17 00:00:00 2001 From: yisaer Date: Tue, 29 Nov 2022 15:58:47 +0800 Subject: [PATCH] address the comment --- planner/core/find_best_task.go | 2 +- planner/core/integration_test.go | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/planner/core/find_best_task.go b/planner/core/find_best_task.go index a6d8b4b68aa8a..2710c9df29b43 100644 --- a/planner/core/find_best_task.go +++ b/planner/core/find_best_task.go @@ -914,7 +914,7 @@ 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.isForUpdateRead { + if path.StoreType == kv.TiFlash && ds.isForUpdateRead && ds.ctx.GetSessionVars().InTxn() { if ds.isPointGetConditions() { continue } diff --git a/planner/core/integration_test.go b/planner/core/integration_test.go index 755e2c5b3ca92..ff2ec6b6fd631 100644 --- a/planner/core/integration_test.go +++ b/planner/core/integration_test.go @@ -7572,6 +7572,7 @@ func TestPointGetWithSelectLock(t *testing.T) { tk.MustExec("set @@tidb_enable_tiflash_read_for_write_stmt = on;") tk.MustExec("set @@tidb_isolation_read_engines='tidb,tiflash';") tk.MustExec("begin;") + // assert point get condition with txn commit and tiflash store 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.MustGetErrMsg("explain select c, d from t1 where c = 1 for update;", "[planner:1815]Internal : Can't find a proper physical plan for this query") tk.MustGetErrMsg("explain select c, d from t1 where c = 1 and d = 1 for update;", "[planner:1815]Internal : Can't find a proper physical plan for this query") @@ -7581,6 +7582,10 @@ func TestPointGetWithSelectLock(t *testing.T) { tk.MustQuery("explain select a, b from t where a = 1 and b = 2 for update;") tk.MustQuery("explain select c, d from t1 where c = 1 for update;") tk.MustExec("commit") + tk.MustExec("set tidb_isolation_read_engines='tidb,tiflash';") + // assert point get condition with auto commit and tiflash store + tk.MustQuery("explain select a, b from t where a = 1 and b = 2 for update;") + tk.MustQuery("explain select c, d from t1 where c = 1 for update;") } func TestTableRangeFallback(t *testing.T) {