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 USE_INDEX_MERGE hint causes a server panic #15991

Closed
mrigger opened this issue Apr 1, 2020 · 1 comment · Fixed by #16001
Closed

A USE_INDEX_MERGE hint causes a server panic #15991

mrigger opened this issue Apr 1, 2020 · 1 comment · Fixed by #16001
Assignees
Labels
epic/sql-plan-management priority/P1 The issue has P1 priority. severity/major sig/planner SIG: Planner type/bug The issue is confirmed as a bug.
Milestone

Comments

@mrigger
Copy link

mrigger commented Apr 1, 2020

Consider the following statements:

CREATE TABLE t0(c0 INT, c1 INT, PRIMARY KEY(c1));
CREATE INDEX i0 ON t0(c0);
SELECT /*+ USE_INDEX_MERGE(t0, PRIMARY) */ * FROM t0 WHERE 1 OR t0.c1;

Unexpectedly, the SELECT causes a server panic:

[2020/04/01 21:32:35.184 +02:00] [ERROR] [conn.go:659] ["connection running loop panic"] [conn=5282] [lastSQL="SELECT /*+ USE_INDEX_MERGE(t0, PRIMARY) */ * FROM t0 WHERE 1 OR t0.c1"] [err="runtime error: invalid memory address or nil pointer dereference"] [stack="goroutine 405232527 [running]:\ngit.luolix.top/pingcap/tidb/server.(*clientConn).Run.func1(0x2cfa760, 0xc0498fe150, 0xc0022bf040)\n\t/tidb/server/conn.go:657 +0xee\npanic(0x2680ea0, 0x3db2c30)\n\t/usr/lib/go-1.13/src/runtime/panic.go:679 +0x1b2\ngit.luolix.top/pingcap/tidb/planner/core.finishCopTask(0x2d32de0, 0xc00105a600, 0x2d10060, 0xc0029ae090, 0xc001bb6420, 0x4118509555555556)\n\t/tidb/planner/core/task.go:677 +0xa1\ngit.luolix.top/pingcap/tidb/planner/core.(*DataSource).convertToIndexMergeScan(0xc001cee3c0, 0xc0048083c0, 0xc000a48ac0, 0x1, 0x4, 0xee6098, 0x10)\n\t/tidb/planner/core/find_best_task.go:567 +0x42f\ngit.luolix.top/pingcap/tidb/planner/core.(*DataSource).findBestTask(0xc001cee3c0, 0xc0048083c0, 0x2d100c0, 0x3db4ac0, 0x0, 0x0)\n\t/tidb/planner/core/find_best_task.go:455 +0x968\ngit.luolix.top/pingcap/tidb/planner/core.(*baseLogicalPlan).findBestTask(0xc001a7a5a0, 0xc004808370, 0x0, 0x0, 0x0, 0x0)\n\t/tidb/planner/core/find_best_task.go:179 +0x61f\ngit.luolix.top/pingcap/tidb/planner/core.physicalOptimize(0x2d31ae0, 0xc001a7a580, 0x20a2, 0x2d31ae0, 0xc001a7a580, 0x2d31ae0, 0xc001a7a580)\n\t/tidb/planner/core/optimizer.go:180 +0xb3\ngit.luolix.top/pingcap/tidb/planner/core.DoOptimize(0x2cfa760, 0xc0498fe150, 0x2d32de0, 0xc00105a600, 0x20a2, 0x2d31ae0, 0xc001a7a580, 0x0, 0x0, 0x0, ...)\n\t/tidb/planner/core/optimizer.go:131 +0xa7\ngit.luolix.top/pingcap/tidb/planner.optimize(0x2cfa760, 0xc0498fe150, 0x2d32de0, 0xc00105a600, 0x2cfc2e0, 0xc0024240d0, 0x2d280c0, 0xc0029565d0, 0x0, 0x0, ...)\n\t/tidb/planner/optimize.go:189 +0x5a9\ngit.luolix.top/pingcap/tidb/planner.Optimize(0x2cfa760, 0xc0498fe150, 0x2d32de0, 0xc00105a600, 0x2cfc2e0, 0xc0024240d0, 0x2d280c0, 0xc0029565d0, 0x0, 0x0, ...)\n\t/tidb/planner/optimize.go:63 +0x28f\ngit.luolix.top/pingcap/tidb/executor.(*Compiler).Compile(0xc00060edc8, 0x2cfa760, 0xc0498fe150, 0x2d01ba0, 0xc0024240d0, 0x0, 0x0, 0x0)\n\t/tidb/executor/compiler.go:61 +0x253\ngit.luolix.top/pingcap/tidb/session.(*session).execute(0xc00105a600, 0x2cfa760, 0xc0498fe150, 0xc0553e0e11, 0x45, 0xc02d12ef00, 0x0, 0x0, 0xc00060f178, 0x240dc1a)\n\t/tidb/session/session.go:1138 +0x5cf\ngit.luolix.top/pingcap/tidb/session.(*session).Execute(0xc00105a600, 0x2cfa760, 0xc0498fe150, 0xc0553e0e11, 0x45, 0x0, 0x0, 0x0, 0x0, 0x0)\n\t/tidb/session/session.go:1089 +0xdb\ngit.luolix.top/pingcap/tidb/server.(*TiDBContext).Execute(0xc00d724990, 0x2cfa760, 0xc0498fe150, 0xc0553e0e11, 0x45, 0xf081e1, 0x2a23570, 0xc00060f278, 0xc00060f268, 0xfa8572)\n\t/tidb/server/driver_tidb.go:248 +0x7c\ngit.luolix.top/pingcap/tidb/server.(*clientConn).handleQuery(0xc0022bf040, 0x2cfa760, 0xc0498fe150, 0xc0553e0e11, 0x45, 0x0, 0x0)\n\t/tidb/server/conn.go:1257 +0x91\ngit.luolix.top/pingcap/tidb/server.(*clientConn).dispatch(0xc0022bf040, 0x2cfa760, 0xc0498fe150, 0xc0553e0e11, 0x46, 0x45, 0x0, 0x0)\n\t/tidb/server/conn.go:898 +0x5e2\ngit.luolix.top/pingcap/tidb/server.(*clientConn).Run(0xc0022bf040, 0x2cfa760, 0xc0498fe150)\n\t/tidb/server/conn.go:712 +0x27c\ngit.luolix.top/pingcap/tidb/server.(*Server).onConn(0xc000171a20, 0xc0022bf040)\n\t/tidb/server/server.go:415 +0xaf9\ncreated by github.com/pingcap/tidb/server.(*Server).Run\n\t/tidb/server/server.go:333 +0x709\n"]

Environment:

mysql> SELECT tidb_version();
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tidb_version()                                                                                                                                                                                                                                                                                          |
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Release Version: v4.0.0-beta.2-160-g82529c886
Git Commit Hash: 82529c886cb1cfff7810476a136acf81284bac6e
Git Branch: master
UTC Build Time: 2020-04-01 11:44:27
GoVersion: go1.13.4
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false |
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
@mrigger mrigger added the type/bug The issue is confirmed as a bug. label Apr 1, 2020
@XuHuaiyu
Copy link
Contributor

XuHuaiyu commented Apr 2, 2020

@eurekaka PTAL

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
epic/sql-plan-management priority/P1 The issue has P1 priority. 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.

6 participants