From 7ef28ab5278a96cd24397e158d50efc1b7886b30 Mon Sep 17 00:00:00 2001 From: xuhuaiyu <391585975@qq.com> Date: Tue, 7 Dec 2021 14:14:52 +0800 Subject: [PATCH] executor: HashJoinExec checks the buildError even if the probeSide is empty --- executor/executor_test.go | 14 ++++++++++++++ executor/join.go | 11 ++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/executor/executor_test.go b/executor/executor_test.go index c821901d5a18d..f503504d739b0 100644 --- a/executor/executor_test.go +++ b/executor/executor_test.go @@ -9487,3 +9487,17 @@ func (s *testSerialSuite) TestIssue28650(c *C) { }() } } + +func (s *testSerialSuite) TestIssue30289(c *C) { + tk := testkit.NewTestKit(c, s.store) + tk.MustExec("use test") + fpName := "github.com/pingcap/tidb/executor/issue30289" + c.Assert(failpoint.Enable(fpName, `return(true)`), IsNil) + defer func() { + c.Assert(failpoint.Disable(fpName), IsNil) + }() + tk.MustExec("drop table if exists t") + tk.MustExec("create table t(a int)") + err := tk.QueryToErr("select /*+ hash_join(t1) */ * from t t1 join t t2 on t1.a=t2.a") + c.Assert(err.Error(), Matches, "issue30289 build return error") +} diff --git a/executor/join.go b/executor/join.go index 2b97c0b1f93cf..eaa43ed538e8b 100644 --- a/executor/join.go +++ b/executor/join.go @@ -214,9 +214,13 @@ func (e *HashJoinExec) fetchProbeSideChunks(ctx context.Context) { return } if !hasWaitedForBuild { + failpoint.Inject("issue30289", func(val failpoint.Value) { + if val.(bool) { + probeSideResult.Reset() + } + }) if probeSideResult.NumRows() == 0 && !e.useOuterToBuild { e.finished.Store(true) - return } emptyBuild, buildErr := e.wait4BuildSide() if buildErr != nil { @@ -264,6 +268,11 @@ func (e *HashJoinExec) fetchBuildSideRows(ctx context.Context, chkCh chan<- *chu } chk := chunk.NewChunkWithCapacity(e.buildSideExec.base().retFieldTypes, e.ctx.GetSessionVars().MaxChunkSize) err = Next(ctx, e.buildSideExec, chk) + failpoint.Inject("issue30289", func(val failpoint.Value) { + if val.(bool) { + err = errors.Errorf("issue30289 build return error") + } + }) if err != nil { e.buildFinished <- errors.Trace(err) return