From d6a2b9a372edd3638c0ed88e1d2a5e6b702a69ed Mon Sep 17 00:00:00 2001 From: Morgan Tocker Date: Wed, 10 Feb 2021 19:46:42 -0700 Subject: [PATCH] server: add tests for empty query hang (#22740) --- server/server_test.go | 16 ++++++++++++++++ server/tidb_test.go | 1 + 2 files changed, 17 insertions(+) diff --git a/server/server_test.go b/server/server_test.go index 391c41ef26ee0..2c6cd86b2edcf 100644 --- a/server/server_test.go +++ b/server/server_test.go @@ -1555,6 +1555,22 @@ func (cli *testServerClient) runTestIssue3680(c *C) { c.Assert(err.Error(), Equals, "Error 1045: Access denied for user 'non_existing_user'@'127.0.0.1' (using password: NO)") } +func (cli *testServerClient) runTestIssue22646(c *C) { + cli.runTests(c, nil, func(dbt *DBTest) { + c1 := make(chan string, 1) + go func() { + dbt.mustExec(``) // empty query. + c1 <- "success" + }() + select { + case res := <-c1: + fmt.Println(res) + case <-time.After(30 * time.Second): + panic("read empty query statement timed out.") + } + }) +} + func (cli *testServerClient) runTestIssue3682(c *C) { cli.runTests(c, nil, func(dbt *DBTest) { dbt.mustExec(`CREATE USER 'issue3682'@'%' IDENTIFIED BY '123';`) diff --git a/server/tidb_test.go b/server/tidb_test.go index d811bda558811..cb2668d49e862 100644 --- a/server/tidb_test.go +++ b/server/tidb_test.go @@ -196,6 +196,7 @@ func (ts *tidbTestSuite) TestIssues(c *C) { c.Parallel() ts.runTestIssue3662(c) ts.runTestIssue3680(c) + ts.runTestIssue22646(c) } func (ts *tidbTestSuite) TestDBNameEscape(c *C) {