Skip to content

Commit 084304b

Browse files
hawkingreiReminiscent
authored andcommitted
planner: fix no access path when TiKV read is disabled under RC isolation (pingcap#65127)
close pingcap#65059
1 parent a1cfa74 commit 084304b

File tree

11 files changed

+685
-42
lines changed

11 files changed

+685
-42
lines changed

pkg/planner/core/casetest/enforcempp/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ go_test(
99
],
1010
data = glob(["testdata/**"]),
1111
flaky = True,
12-
shard_count = 13,
12+
shard_count = 14,
1313
deps = [
1414
"//pkg/domain",
1515
"//pkg/meta/model",

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

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -664,3 +664,31 @@ func TestEnforceMPPNewest(t *testing.T) {
664664
}
665665
})
666666
}
667+
668+
func TestReadCommittedWithTiflash(t *testing.T) {
669+
store, dom := testkit.CreateMockStoreAndDomain(t)
670+
tk := testkit.NewTestKit(t, store)
671+
tk.MustExec(`use test`)
672+
tk.MustExec(`create table t1(a int primary key, b int);`)
673+
tk.MustExec(`create table t2(a int primary key, b int);`)
674+
testkit.SetTiFlashReplica(t, dom, "test", "t1")
675+
testkit.SetTiFlashReplica(t, dom, "test", "t2")
676+
tk.MustExec(`set tx_isolation="READ-COMMITTED";`)
677+
tk.MustExec("set @@session.tidb_isolation_read_engines=\"tidb,tiflash\"")
678+
tk.MustExec("begin;")
679+
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(
680+
`TableReader root MppVersion: 3, data:ExchangeSender`,
681+
`└─ExchangeSender mpp[tiflash] ExchangeType: PassThrough`,
682+
` └─HashJoin mpp[tiflash] inner join, equal:[eq(test.t1.a, test.t2.b)]`,
683+
` ├─ExchangeReceiver(Build) mpp[tiflash] `,
684+
` │ └─ExchangeSender mpp[tiflash] ExchangeType: Broadcast, Compression: FAST`,
685+
` │ └─TableRangeScan mpp[tiflash] table:t1 range:[1,1], [2,2], keep order:false, stats:pseudo`,
686+
` └─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`))
687+
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(
688+
`HashJoin root inner join, equal:[eq(test.t1.a, test.t2.b)]`,
689+
`├─Batch_Point_Get(Build) root table:t1 handle:[1 2], keep order:false, desc:false`,
690+
`└─TableReader(Probe) root MppVersion: 3, data:ExchangeSender`,
691+
` └─ExchangeSender mpp[tiflash] ExchangeType: PassThrough`,
692+
` └─TableFullScan mpp[tiflash] table:t2 pushed down filter:in(test.t2.b, 1, 2), not(isnull(test.t2.b)), keep order:false, stats:pseudo`))
693+
tk.MustExec("commit;")
694+
}

pkg/planner/core/casetest/tpch/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ go_test(
99
],
1010
data = glob(["testdata/**"]),
1111
flaky = True,
12-
shard_count = 12,
12+
shard_count = 13,
1313
deps = [
1414
"//pkg/config",
1515
"//pkg/domain",

pkg/planner/core/casetest/tpch/testdata/tpch_suite_in.json

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,17 @@
1414
{
1515
"name": "TestQ3",
1616
"cases": [
17-
"explain format='brief' select /*+ HASH_JOIN(orders, lineitem, customer) */ l_orderkey, sum(l_extendedprice * (1 - l_discount)) as revenue, o_orderdate, o_shippriority from customer, orders, lineitem where c_mktsegment = 'AUTOMOBILE' and c_custkey = o_custkey and l_orderkey = o_orderkey and o_orderdate < '1995-03-13' and l_shipdate > '1995-03-13' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate limit 10;",
18-
"explain format='brief' SELECT /*+ HASH_JOIN(orders, lineitem, customer) */ l_orderkey, SUM(l_extendedprice * (1 - l_discount)) AS revenue, o_orderdate, o_shippriority FROM customer AS c LEFT JOIN orders AS o ON c.c_custkey = o.o_custkey LEFT JOIN lineitem AS l ON l.l_orderkey = o.o_orderkey WHERE c.c_mktsegment = 'AUTOMOBILE' AND o.o_orderdate < '1995-03-13' AND l.l_shipdate > '1995-03-13' GROUP BY l_orderkey, o_orderdate, o_shippriority ORDER BY revenue DESC, o_orderdate LIMIT 10;",
19-
"explain format='brief' SELECT /*+ SHUFFLE_JOIN(orders, lineitem) */ o.o_orderdate, SUM(l.l_extendedprice * (1 - l.l_discount)) AS revenue FROM orders AS o JOIN lineitem AS l ON o.o_orderkey = l.l_orderkey WHERE o.o_orderdate BETWEEN '1994-01-01' AND '1994-12-31' GROUP BY o.o_orderdate ORDER BY revenue DESC LIMIT 10;"
17+
"explain format='brief' select /*+ HASH_JOIN(orders, lineitem, customer) */ l_orderkey, sum(l_extendedprice * (1 - l_discount)) as revenue, o_orderdate, o_shippriority from customer, orders, lineitem where c_mktsegment = 'AUTOMOBILE' and c_custkey = o_custkey and l_orderkey = o_orderkey and o_orderdate < '1995-03-13' and l_shipdate > '1995-03-13' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate limit 10",
18+
"explain format='brief' SELECT /*+ HASH_JOIN(orders, lineitem, customer) */ l_orderkey, SUM(l_extendedprice * (1 - l_discount)) AS revenue, o_orderdate, o_shippriority FROM customer AS c LEFT JOIN orders AS o ON c.c_custkey = o.o_custkey LEFT JOIN lineitem AS l ON l.l_orderkey = o.o_orderkey WHERE c.c_mktsegment = 'AUTOMOBILE' AND o.o_orderdate < '1995-03-13' AND l.l_shipdate > '1995-03-13' GROUP BY l_orderkey, o_orderdate, o_shippriority ORDER BY revenue DESC, o_orderdate LIMIT 10",
19+
"explain format='brief' SELECT /*+ SHUFFLE_JOIN(orders, lineitem) */ o.o_orderdate, SUM(l.l_extendedprice * (1 - l.l_discount)) AS revenue FROM orders AS o JOIN lineitem AS l ON o.o_orderkey = l.l_orderkey WHERE o.o_orderdate BETWEEN '1994-01-01' AND '1994-12-31' GROUP BY o.o_orderdate ORDER BY revenue DESC LIMIT 10"
20+
]
21+
},
22+
{
23+
"name": "TestQ3RCAndDisableTikv",
24+
"cases": [
25+
"explain format='brief' select /*+ HASH_JOIN(orders, lineitem, customer) */ l_orderkey, sum(l_extendedprice * (1 - l_discount)) as revenue, o_orderdate, o_shippriority from customer, orders, lineitem where c_mktsegment = 'AUTOMOBILE' and c_custkey = o_custkey and l_orderkey = o_orderkey and o_orderdate < '1995-03-13' and l_shipdate > '1995-03-13' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate limit 10",
26+
"explain format='brief' SELECT /*+ HASH_JOIN(orders, lineitem, customer) */ l_orderkey, SUM(l_extendedprice * (1 - l_discount)) AS revenue, o_orderdate, o_shippriority FROM customer AS c LEFT JOIN orders AS o ON c.c_custkey = o.o_custkey LEFT JOIN lineitem AS l ON l.l_orderkey = o.o_orderkey WHERE c.c_mktsegment = 'AUTOMOBILE' AND o.o_orderdate < '1995-03-13' AND l.l_shipdate > '1995-03-13' GROUP BY l_orderkey, o_orderdate, o_shippriority ORDER BY revenue DESC, o_orderdate LIMIT 10",
27+
"explain format='brief' SELECT /*+ SHUFFLE_JOIN(orders, lineitem) */ o.o_orderdate, SUM(l.l_extendedprice * (1 - l.l_discount)) AS revenue FROM orders AS o JOIN lineitem AS l ON o.o_orderkey = l.l_orderkey WHERE o.o_orderdate BETWEEN '1994-01-01' AND '1994-12-31' GROUP BY o.o_orderdate ORDER BY revenue DESC LIMIT 10"
2028
]
2129
},
2230
{

0 commit comments

Comments
 (0)