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

create binding cause connection panic #29503

Closed
XuHuaiyu opened this issue Nov 5, 2021 · 2 comments · Fixed by #29519
Closed

create binding cause connection panic #29503

XuHuaiyu opened this issue Nov 5, 2021 · 2 comments · Fixed by #29519
Assignees
Labels
affects-4.0 This bug affects 4.0.x versions. affects-5.0 This bug affects 5.0.x versions. affects-5.1 This bug affects 5.1.x versions. affects-5.2 This bug affects 5.2.x versions. affects-5.3 This bug affects 5.3.x versions. severity/major sig/planner SIG: Planner type/bug The issue is confirmed as a bug.

Comments

@XuHuaiyu
Copy link
Contributor

XuHuaiyu commented Nov 5, 2021

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

set the tidb config item status.record-db-qp to true

create binding for select 1 using select 1;
create binding for select a from t using select a from t;

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

The 2 queries run successfully

3. What did you see instead (Required)

panic happens

create binding for select 1 using select 1;

[2021/11/05 14:20:58.134 +08:00] [ERROR] [conn.go:974] ["connection running loop panic"] [conn=5] [lastSQL="create  binding for select 1 using select 1"] [err="runtime error: invalid memory address or nil pointer dereference"] [stack="goroutine 631 [running]:\ngithub.com/pingcap/tidb/server.(*clientConn).Run.func1(0x6f94fd0, 0xc01109ea20, 0xc01068ef00)\n\t/Users/xuhuaiyu/Development/GOPATH/src/github.com/pingcap/tidb/server/conn.go:972 +0xf5\npanic(0x65f97c0, 0x8b34ff0)\n\t/Users/xuhuaiyu/.gvm/gos/go1.16/src/runtime/panic.go:965 +0x1b9\ngithub.com/pingcap/tidb/planner/core.extractTableList(0x6fadc08, 0xc010863950, 0x0, 0x0, 0x0, 0x203000, 0x8, 0x0, 0x203004)\n\t/Users/xuhuaiyu/Development/GOPATH/src/github.com/pingcap/tidb/planner/core/logical_plan_builder.go:5944 +0xd9d\ngithub.com/pingcap/tidb/planner/core.(*preprocessor).checkBindGrammar(0xc010e6b1a0, 0x6fb3958, 0xc010863950, 0x6fb3958, 0xc010863a40, 0xc0106b69dc, 0x4)\n\t/Users/xuhuaiyu/Development/GOPATH/src/github.com/pingcap/tidb/planner/core/preprocess.go:440 +0x196\ngithub.com/pingcap/tidb/planner/core.(*preprocessor).Enter(0xc010e6b1a0, 0x6fac390, 0xc010ee2400, 0xc0113d8928, 0x401438d, 0x68d8c60)\n\t/Users/xuhuaiyu/Development/GOPATH/src/github.com/pingcap/tidb/planner/core/preprocess.go:245 +0x28f\ngithub.com/pingcap/tidb/parser/ast.(*CreateBindingStmt).Accept(0xc010ee2400, 0x6f714b8, 0xc010e6b1a0, 0x8c0e830, 0xc0113d8988, 0x4010c45)\n\t/Users/xuhuaiyu/Development/GOPATH/src/github.com/pingcap/tidb/parser/ast/misc.go:1604 +0x4b\ngithub.com/pingcap/tidb/planner/core.Preprocess(0x6fdebf8, 0xc00f939e00, 0x6fac390, 0xc010ee2400, 0xc0113d8a98, 0x2, 0x2, 0x10, 0xc010e66ce0)\n\t/Users/xuhuaiyu/Development/GOPATH/src/github.com/pingcap/tidb/planner/core/preprocess.go:117 +0x129\ngithub.com/pingcap/tidb/executor.(*Compiler).Compile(0xc0113d8be0, 0x6f94fd0, 0xc010e63a70, 0x6fb2918, 0xc010ee2400, 0x0, 0x0, 0x0)\n\t/Users/xuhuaiyu/Development/GOPATH/src/github.com/pingcap/tidb/executor/compiler.go:60 +0x256\ngithub.com/pingcap/tidb/session.(*session).ExecuteStmt(0xc00f939e00, 0x6f94fd0, 0xc010e63a70, 0x6fb2918, 0xc010ee2400, 0x0, 0x0, 0x0, 0x0)\n\t/Users/xuhuaiyu/Development/GOPATH/src/github.com/pingcap/tidb/session/session.go:1559 +0x4c9\ngithub.com/pingcap/tidb/server.(*TiDBContext).ExecuteStmt(0xc01109f320, 0x6f94fd0, 0xc010e63a70, 0x6fb2918, 0xc010ee2400, 0xc0105d7a20, 0x6f94fd0, 0xc010e63a70, 0x0)\n\t/Users/xuhuaiyu/Development/GOPATH/src/github.com/pingcap/tidb/server/driver_tidb.go:219 +0x6b\ngithub.com/pingcap/tidb/server.(*clientConn).handleStmt(0xc01068ef00, 0x6f94f28, 0xc010e63a70, 0x6fb2918, 0xc010ee2400, 0x8c0e830, 0x0, 0x0, 0x1, 0x0, ...)\n\t/Users/xuhuaiyu/Development/GOPATH/src/github.com/pingcap/tidb/server/conn.go:1906 +0x1d1\ngithub.com/pingcap/tidb/server.(*clientConn).handleQuery(0xc01068ef00, 0x6f94f28, 0xc010ee2380, 0xc010c48421, 0x2b, 0x0, 0x0)\n\t/Users/xuhuaiyu/Development/GOPATH/src/github.com/pingcap/tidb/server/conn.go:1775 +0x498\ngithub.com/pingcap/tidb/server.(*clientConn).dispatch(0xc01068ef00, 0x6f94f28, 0xc010ee2380, 0xc010c48420, 0x2c, 0x2b, 0x0, 0x0)\n\t/Users/xuhuaiyu/Development/GOPATH/src/github.com/pingcap/tidb/server/conn.go:1279 +0xafd\ngithub.com/pingcap/tidb/server.(*clientConn).Run(0xc01068ef00, 0x6f94fd0, 0xc01109ea20)\n\t/Users/xuhuaiyu/Development/GOPATH/src/github.com/pingcap/tidb/server/conn.go:1034 +0x2bc\ngithub.com/pingcap/tidb/server.(*Server).onConn(0xc00faebba0, 0xc01068ef00)\n\t/Users/xuhuaiyu/Development/GOPATH/src/github.com/pingcap/tidb/server/server.go:550 +0xa93\ncreated by github.com/pingcap/tidb/server.(*Server).startNetworkListener\n\t/Users/xuhuaiyu/Development/GOPATH/src/github.com/pingcap/tidb/server/server.go:453 +0x91c\n"]

create binding for select a from t using select a from t;

[2021/11/05 14:20:54.495 +08:00] [ERROR] [conn.go:974] ["connection running loop panic"] [conn=3] [lastSQL="create binding for select a from t using select a from t"] [err="runtime error: invalid memory address or nil pointer dereference"] [stack="goroutine 424 [running]:\ngit.luolix.top/pingcap/tidb/server.(*clientConn).Run.func1(0x6f94fd0, 0xc00fe5ca50, 0xc00f9df540)\n\t/Users/xuhuaiyu/Development/GOPATH/src/github.com/pingcap/tidb/server/conn.go:972 +0xf5\npanic(0x65f97c0, 0x8b34ff0)\n\t/Users/xuhuaiyu/.gvm/gos/go1.16/src/runtime/panic.go:965 +0x1b9\ngit.luolix.top/pingcap/tidb/executor.getDbFromResultNode(0x6fb3d68, 0xc00f93af20, 0xc00ffa47f0, 0x4823410, 0x319b7930)\n\t/Users/xuhuaiyu/Development/GOPATH/src/github.com/pingcap/tidb/executor/compiler.go:291 +0x1b5\ngit.luolix.top/pingcap/tidb/executor.getDbFromResultNode(0x6fb3db8, 0xc0009682d0, 0x48221ca, 0xc000500480, 0x0)\n\t/Users/xuhuaiyu/Development/GOPATH/src/github.com/pingcap/tidb/executor/compiler.go:285 +0x9d\ngit.luolix.top/pingcap/tidb/executor.getDbFromResultNode(0x6fb33b8, 0xc00fe7d2d0, 0x1, 0xc00ffa4850, 0x4010ce5)\n\t/Users/xuhuaiyu/Development/GOPATH/src/github.com/pingcap/tidb/executor/compiler.go:294 +0x3db\ngit.luolix.top/pingcap/tidb/executor.getStmtDbLabel(0x6fb2918, 0xc00fc37000, 0x1)\n\t/Users/xuhuaiyu/Development/GOPATH/src/github.com/pingcap/tidb/executor/compiler.go:249 +0x5e6\ngit.luolix.top/pingcap/tidb/executor.CountStmtNode(0x6fb2918, 0xc00fc37000, 0x6fdeb00)\n\t/Users/xuhuaiyu/Development/GOPATH/src/github.com/pingcap/tidb/executor/compiler.go:178 +0x174\ngit.luolix.top/pingcap/tidb/executor.(*Compiler).Compile(0xc00ffa4be0, 0x6f94fd0, 0xc00fe5dc80, 0x6fb2918, 0xc00fc37000, 0x0, 0x0, 0x0)\n\t/Users/xuhuaiyu/Development/GOPATH/src/github.com/pingcap/tidb/executor/compiler.go:79 +0x4ad\ngit.luolix.top/pingcap/tidb/session.(*session).ExecuteStmt(0xc00f9aa800, 0x6f94fd0, 0xc00fe5dc80, 0x6fb2918, 0xc00fc37000, 0x0, 0x0, 0x0, 0x0)\n\t/Users/xuhuaiyu/Development/GOPATH/src/github.com/pingcap/tidb/session/session.go:1559 +0x4c9\ngit.luolix.top/pingcap/tidb/server.(*TiDBContext).ExecuteStmt(0xc00fe5d350, 0x6f94fd0, 0xc00fe5dc80, 0x6fb2918, 0xc00fc37000, 0xc0007336e0, 0x6f94fd0, 0xc00fe5dc80, 0x0)\n\t/Users/xuhuaiyu/Development/GOPATH/src/github.com/pingcap/tidb/server/driver_tidb.go:219 +0x6b\ngit.luolix.top/pingcap/tidb/server.(*clientConn).handleStmt(0xc00f9df540, 0x6f94f28, 0xc00fe5dc80, 0x6fb2918, 0xc00fc37000, 0x8c0e830, 0x0, 0x0, 0x1, 0x0, ...)\n\t/Users/xuhuaiyu/Development/GOPATH/src/github.com/pingcap/tidb/server/conn.go:1906 +0x1d1\ngit.luolix.top/pingcap/tidb/server.(*clientConn).handleQuery(0xc00f9df540, 0x6f94f28, 0xc00fc36f80, 0xc00f933981, 0x38, 0x0, 0x0)\n\t/Users/xuhuaiyu/Development/GOPATH/src/github.com/pingcap/tidb/server/conn.go:1775 +0x498\ngit.luolix.top/pingcap/tidb/server.(*clientConn).dispatch(0xc00f9df540, 0x6f94f28, 0xc00fc36f80, 0xc00f933980, 0x39, 0x38, 0x0, 0x0)\n\t/Users/xuhuaiyu/Development/GOPATH/src/github.com/pingcap/tidb/server/conn.go:1279 +0xafd\ngit.luolix.top/pingcap/tidb/server.(*clientConn).Run(0xc00f9df540, 0x6f94fd0, 0xc00fe5ca50)\n\t/Users/xuhuaiyu/Development/GOPATH/src/github.com/pingcap/tidb/server/conn.go:1034 +0x2bc\ngit.luolix.top/pingcap/tidb/server.(*Server).onConn(0xc00faebba0, 0xc00f9df540)\n\t/Users/xuhuaiyu/Development/GOPATH/src/github.com/pingcap/tidb/server/server.go:550 +0xa93\ncreated by github.com/pingcap/tidb/server.(*Server).startNetworkListener\n\t/Users/xuhuaiyu/Development/GOPATH/src/github.com/pingcap/tidb/server/server.go:453 +0x91c\n"]

4. What is your TiDB version? (Required)

651e910

@XuHuaiyu XuHuaiyu added type/bug The issue is confirmed as a bug. sig/planner SIG: Planner affects-4.0 This bug affects 4.0.x versions. affects-5.0 This bug affects 5.0.x versions. affects-5.1 This bug affects 5.1.x versions. affects-5.2 This bug affects 5.2.x versions. affects-5.3 This bug affects 5.3.x versions. labels Nov 5, 2021
@Reminiscent
Copy link
Contributor

Related to #9151

@github-actions
Copy link

github-actions bot commented Nov 8, 2021

Please check whether the issue should be labeled with 'affects-x.y' or 'fixes-x.y.z', and then remove 'needs-more-info' label.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-4.0 This bug affects 4.0.x versions. affects-5.0 This bug affects 5.0.x versions. affects-5.1 This bug affects 5.1.x versions. affects-5.2 This bug affects 5.2.x versions. affects-5.3 This bug affects 5.3.x versions. severity/major sig/planner SIG: Planner type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants