Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A recursive CTE causes TiDB server panic #26112

Closed
francis0407 opened this issue Jul 11, 2021 · 1 comment · Fixed by #26129
Closed

A recursive CTE causes TiDB server panic #26112

francis0407 opened this issue Jul 11, 2021 · 1 comment · Fixed by #26129
Assignees
Labels
severity/major sig/execution SIG execution type/bug The issue is confirmed as a bug.

Comments

@francis0407
Copy link
Member

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

with recursive 
c(p) as (select 1), 
cte(a, b) as (select 1, 1 union select a+1, 1 from cte, c where a < 5) 
select * from cte;

2. What did you expect to see? (Required)

+---+---+
| a | b |
+---+---+
| 1 | 1 |
| 2 | 1 |
| 3 | 1 |
| 4 | 1 |
| 5 | 1 |
+---+---+
5 rows in set (0.01 sec)

3. What did you see instead (Required)

mysql> with recursive c(p) as (select 1), cte(a, b) as (select 1, 1 union select a+1, 1 from cte, c where a < 5) select * from cte;
ERROR 1105 (HY000): close of closed channel
[2021/07/11 20:18:50.476 +08:00] [ERROR] [conn.go:918] ["connection running loop panic"] [conn=13] [lastSQL="with recursive c(p) as (select 1), cte(a, b) as (select 1, 1 union select a+1, 1 from cte, c where a < 5) select * from cte"] [err="close of closed channel"] [stack="goroutine 93813 [running]:\ngithub.com/pingcap/tidb/server.(*clientConn).Run.func1(0x3c3e238, 0xc010e462a0, 0xc010966000)\n\t/home/francis/tidb/tidb/server/conn.go:916 +0xf5\npanic(0x33864e0, 0x3bbc860)\n\t/home/francis/App/go/src/runtime/panic.go:965 +0x1b9\ngithub.com/pingcap/tidb/executor.(*HashJoinExec).Close(0xc000a59c00, 0x0, 0xc0113128a0)\n\t/home/francis/tidb/tidb/executor/join.go:117 +0x47\ngithub.com/pingcap/tidb/executor.(*baseExecutor).Close(0xc00fa81300, 0x15, 0x3c3ecf0)\n\t/home/francis/tidb/tidb/executor/executor.go:181 +0x7e\ngithub.com/pingcap/tidb/executor.(*ProjectionExec).Close(0xc00fa81300, 0x0, 0x0)\n\t/home/francis/tidb/tidb/executor/projection.go:328 +0x138\ngithub.com/pingcap/tidb/executor.(*CTEExec).Close(0xc011339e00, 0x0, 0x0)\n\t/home/francis/tidb/tidb/executor/cte.go:196 +0x122\ngithub.com/pingcap/tidb/executor.(*recordSet).Close(0xc011633180, 0x0, 0x0)\n\t/home/francis/tidb/tidb/executor/adapter.go:169 +0x38\ngithub.com/pingcap/tidb/session.(*execStmtResult).Close(0xc010e551a0, 0xc010e551a0, 0x3c3e238)\n\t/home/francis/tidb/tidb/session/session.go:1687 +0x64\ngithub.com/pingcap/tidb/server.(*tidbResultSet).Close(0xc0116331d0, 0xc01134b0c8, 0xc011e42fc8)\n\t/home/francis/tidb/tidb/server/driver_tidb.go:323 +0x4a\ngithub.com/pingcap/parser/terror.Call(0xc011e43108)\n\t/home/francis/go/pkg/mod/github.com/pingcap/parser@v0.0.0-20210618124025-07ae8d9291c4/terror/terror.go:282 +0x3f\ngithub.com/pingcap/tidb/server.(*clientConn).handleStmt(0xc010966000, 0x3c3e190, 0xc0119510e0, 0x3c58938, 0xc010f50c30, 0x58203e0, 0x0, 0x0, 0x1, 0x1, ...)\n\t/home/francis/tidb/tidb/server/conn.go:1836 +0x445\ngithub.com/pingcap/tidb/server.(*clientConn).handleQuery(0xc010966000, 0x3c3e190, 0xc010a00740, 0xc012260201, 0x7b, 0x0, 0x0)\n\t/home/francis/tidb/tidb/server/conn.go:1680 +0x492\ngithub.com/pingcap/tidb/server.(*clientConn).dispatch(0xc010966000, 0x3c3e190, 0xc010a00740, 0xc012260200, 0x7c, 0x7b, 0x0, 0x0)\n\t/home/francis/tidb/tidb/server/conn.go:1214 +0xafd\ngithub.com/pingcap/tidb/server.(*clientConn).Run(0xc010966000, 0x3c3e238, 0xc010e462a0)\n\t/home/francis/tidb/tidb/server/conn.go:977 +0x296\ngithub.com/pingcap/tidb/server.(*Server).onConn(0xc0001ff930, 0xc010966000)\n\t/home/francis/tidb/tidb/server/server.go:485 +0xa7e\ncreated by github.com/pingcap/tidb/server.(*Server).Run\n\t/home/francis/tidb/tidb/server/server.go:388 +0x8d5\n"]

4. What is your TiDB version? (Required)

mysql> select tidb_version();
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tidb_version()                                                                                                                                                                                                                                                                                                            |
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Release Version: v4.0.0-beta.2-3360-ga6984c5
Edition: Community
Git Commit Hash: a6984c504406c8a15f2ac88c94713435e959cb1a
Git Branch: master
UTC Build Time: 2021-07-06 12:14:42
GoVersion: go1.16.5
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false |
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
@ti-srebot
Copy link
Contributor

Please edit this comment or add a new comment to complete the following information

Not a bug

  1. Remove the 'type/bug' label
  2. Add notes to indicate why it is not a bug

Duplicate bug

  1. Add the 'type/duplicate' label
  2. Add the link to the original bug

Bug

Note: Make Sure that 'component', and 'severity' labels are added
Example for how to fill out the template: #20100

1. Root Cause Analysis (RCA) (optional)

2. Symptom (optional)

3. All Trigger Conditions (optional)

4. Workaround (optional)

5. Affected versions

6. Fixed versions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
severity/major sig/execution SIG execution type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants