diff --git a/executor/executor_test.go b/executor/executor_test.go index 3ceb70b8d726a..afe5fe53cc4cf 100644 --- a/executor/executor_test.go +++ b/executor/executor_test.go @@ -8994,3 +8994,15 @@ func (s *testSuite) TestCTEWithIndexLookupJoinDeadLock(c *C) { tk.MustExec("with cte as (with cte1 as (select * from t2 use index(idx_ab) where a > 1 and b > 1) select * from cte1) select /*+use_index(t1 idx_ab)*/ * from cte join t1 on t1.a=cte.a;") } } + +func (s *testSuite) TestCTEWithIndexLookupJoinDeadLock(c *C) { + tk := testkit.NewTestKit(c, s.store) + tk.MustExec("use test") + tk.MustExec("create table t (a int(11) default null,b int(11) default null,key b (b),key ba (b))") + tk.MustExec("create table t1 (a int(11) default null,b int(11) default null,key idx_ab (a,b),key idx_a (a),key idx_b (b))") + tk.MustExec("create table t2 (a int(11) default null,b int(11) default null,key idx_ab (a,b),key idx_a (a),key idx_b (b))") + // It's easy to reproduce this problem in 30 times execution of IndexLookUpJoin. + for i := 0; i < 30; i++ { + tk.MustExec("with cte as (with cte1 as (select * from t2 use index(idx_ab) where a > 1 and b > 1) select * from cte1) select /*+use_index(t1 idx_ab)*/ * from cte join t1 on t1.a=cte.a;") + } +}