Skip to content

Commit 31c7b06

Browse files
committed
update
Signed-off-by: Weizhen Wang <wangweizhen@pingcap.com>
1 parent 95d2201 commit 31c7b06

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

pkg/planner/core/casetest/enforcempp/enforce_mpp_test.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -646,11 +646,13 @@ func TestReadCommittedWithTiflash(t *testing.T) {
646646
tk.MustExec("set @@session.tidb_isolation_read_engines=\"tidb,tiflash\"")
647647
tk.MustExec("begin;")
648648
tk.MustQuery(`explain format='plan_tree' select /*+ set_var(tidb_enforce_mpp=on) */ * from t1 join t2 on t1.a=t2.b where t1.a in (1,2);`).Check(testkit.Rows(
649-
`HashJoin root inner join, equal:[eq(test.t1.a, test.t2.b)]`,
650-
`├─Batch_Point_Get(Build) root table:t1 handle:[1 2], keep order:false, desc:false`,
651-
`└─TableReader(Probe) root MppVersion: 3, data:ExchangeSender`,
652-
` └─ExchangeSender mpp[tiflash] ExchangeType: PassThrough`,
653-
` └─TableFullScan mpp[tiflash] table:t2 pushed down filter:in(test.t2.b, 1, 2), not(isnull(test.t2.b)), keep order:false, stats:pseudo`))
649+
`TableReader root MppVersion: 3, data:ExchangeSender`,
650+
`└─ExchangeSender mpp[tiflash] ExchangeType: PassThrough`,
651+
` └─HashJoin mpp[tiflash] inner join, equal:[eq(test.t1.a, test.t2.b)]`,
652+
` ├─ExchangeReceiver(Build) mpp[tiflash] `,
653+
` │ └─ExchangeSender mpp[tiflash] ExchangeType: Broadcast, Compression: FAST`,
654+
` │ └─TableRangeScan mpp[tiflash] table:t1 range:[1,1], [2,2], keep order:false, stats:pseudo`,
655+
` └─TableFullScan(Probe) mpp[tiflash] table:t2 pushed down filter:in(test.t2.b, 1, 2), not(isnull(test.t2.b)), keep order:false, stats:pseudo`))
654656
tk.MustQuery(`explain format='plan_tree' select * from t1 join t2 on t1.a=t2.b where t1.a in (1,2);`).Check(testkit.Rows(
655657
`HashJoin root inner join, equal:[eq(test.t1.a, test.t2.b)]`,
656658
`├─Batch_Point_Get(Build) root table:t1 handle:[1 2], keep order:false, desc:false`,

pkg/planner/core/find_best_task.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1643,7 +1643,7 @@ func findBestTask4LogicalDataSource(super base.LogicalPlan, prop *property.Physi
16431643
}
16441644
sessionVars := ds.SCtx().GetSessionVars()
16451645
_, isolationReadEnginesHasTiKV := sessionVars.GetIsolationReadEngines()[kv.TiKV]
1646-
if ds.IsForUpdateRead && sessionVars.TxnCtx.IsExplicit && isolationReadEnginesHasTiKV {
1646+
if ds.IsForUpdateRead && sessionVars.TxnCtx.IsExplicit && isolationReadEnginesHasTiKV && !sessionVars.IsMPPEnforced() {
16471647
hasPointGetPath := false
16481648
for _, path := range ds.PossibleAccessPaths {
16491649
if isPointGetPath(ds, path) {

pkg/planner/core/logical_plan_builder.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ func setPreferredStoreType(ds *logicalop.DataSource, hintInfo *h.PlanHints) {
522522
ds.SCtx().GetSessionVars().RaiseWarningWhenMPPEnforced("MPP mode may be blocked because you have set a hint to read table `" + hintTbl.TblName.O + "` from TiKV.")
523523
}
524524
}
525-
if hintTbl := hintInfo.IfPreferTiFlash(alias); hintTbl != nil {
525+
if hintTbl := hintInfo.IfPreferTiFlash(alias); hintTbl != nil || ds.SCtx().GetSessionVars().IsMPPEnforced() {
526526
// `ds.PreferStoreType != 0`, which means there's a hint hit the both TiKV value and TiFlash value for table.
527527
// We can't support read a table from two different storages, even partition table.
528528
if ds.PreferStoreType != 0 {
@@ -535,7 +535,9 @@ func setPreferredStoreType(ds *logicalop.DataSource, hintInfo *h.PlanHints) {
535535
for _, path := range ds.AllPossibleAccessPaths {
536536
if path.StoreType == kv.TiFlash {
537537
ds.PreferStoreType |= h.PreferTiFlash
538-
ds.PreferPartitions[h.PreferTiFlash] = hintTbl.Partitions
538+
if hintTbl != nil {
539+
ds.PreferPartitions[h.PreferTiFlash] = hintTbl.Partitions
540+
}
539541
break
540542
}
541543
}

0 commit comments

Comments
 (0)