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

Join reorder occurs "index out of range" error #24095

Closed
hanfei1991 opened this issue Apr 16, 2021 · 3 comments · Fixed by #24102
Closed

Join reorder occurs "index out of range" error #24095

hanfei1991 opened this issue Apr 16, 2021 · 3 comments · Fixed by #24102
Assignees
Labels
affects-5.0 This bug affects 5.0.x versions. severity/major sig/planner SIG: Planner type/bug The issue is confirmed as a bug.

Comments

@hanfei1991
Copy link
Member

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

mysql> create table t (id int, value decimal(10,5));
Query OK, 0 rows affected (0.01 sec)

mysql> desc format = 'brief' select count(*) from t join (select t.id, t.value v1 from t join t t1 on t.id = t1.id order by t.value limit 1) v on v.id = t.id and v.v1 = t.value;
ERROR 1105 (HY000): runtime error: index out of range [4] with length 4

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

Empty result

3. What did you see instead (Required)

Error

4. What is your TiDB version? (Required)

Master (873fbfd)

@hanfei1991 hanfei1991 added the type/bug The issue is confirmed as a bug. label Apr 16, 2021
@mmyj
Copy link
Member

mmyj commented Apr 17, 2021

/assign

@XuHuaiyu
Copy link
Contributor

error message:

[2021/04/19 09:49:51.672 +08:00] [ERROR] [conn.go:802] ["connection running loop panic"] [conn=3] [lastSQL="desc format = 'brief' select count(*) from t join (select t.id, t.value v1 from t join t t1 on t.id = t1.id order by t.value limit 1) v on v.id = t.id and v.v1 = t.value"] [err="runtime error: index out of range [4] with length 4"] [stack="goroutine 531 [running]:\ngithub.com/pingcap/tidb/server.(*clientConn).Run.func1(0x6c23780, 0xc00f71bf50, 0xc000299000)\n\t/Users/xuhuaiyu/Development/GOPATH/src/github.com/pingcap/tidb/server/conn.go:800 +0xee\npanic(0x63cea20, 0xc010dfcc60)\n\t/Users/xuhuaiyu/.gvm/gos/go1.13/src/runtime/panic.go:679 +0x1b2\ngithub.com/pingcap/tidb/planner/core.(*joinReOrderSolver).optimizeRecursive(0x896ec60, 0x6c7c880, 0xc00fc5cb40, 0x6c77bc0, 0xc000447340, 0x0, 0x0, 0x0, 0x0)\n\t/Users/xuhuaiyu/Development/GOPATH/src/github.com/pingcap/tidb/planner/core/rule_join_reorder.go:95 +0xa4d\ngithub.com/pingcap/tidb/planner/core.(*joinReOrderSolver).optimizeRecursive(0x896ec60, 0x6c7c880, 0xc00fc5cb40, 0x6c778c0, 0xc010e1d2c0, 0x0, 0x0, 0x0, 0x0)\n\t/Users/xuhuaiyu/Development/GOPATH/src/github.com/pingcap/tidb/planner/core/rule_join_reorder.go:112 +0x894\ngithub.com/pingcap/tidb/planner/core.(*joinReOrderSolver).optimizeRecursive(0x896ec60, 0x6c7c880, 0xc00fc5cb40, 0x6c781c0, 0xc010baf880, 0xc010baf800, 0xc00f704360, 0x62f8340, 0xc00f704360)\n\t/Users/xuhuaiyu/Development/GOPATH/src/github.com/pingcap/tidb/planner/core/rule_join_reorder.go:112 +0x894\ngithub.com/pingcap/tidb/planner/core.(*joinReOrderSolver).optimize(0x896ec60, 0x6c23780, 0xc010d5b7d0, 0x6c781c0, 0xc010baf880, 0x6c781c0, 0xc010baf880, 0x0, 0x0)\n\t/Users/xuhuaiyu/Development/GOPATH/src/github.com/pingcap/tidb/planner/core/rule_join_reorder.go:58 +0x5a\ngithub.com/pingcap/tidb/planner/core.logicalOptimize(0x6c23780, 0xc010d5b7d0, 0x3cf6, 0x6c781c0, 0xc010baf880, 0x607ce1bf, 0xc010777bf8, 0x408c806, 0x607ce1bf)\n\t/Users/xuhuaiyu/Development/GOPATH/src/github.com/pingcap/tidb/planner/core/optimizer.go:206 +0x116\ngithub.com/pingcap/tidb/planner/core.DoOptimize(0x6c23780, 0xc010d5b7d0, 0x6c7c880, 0xc00fc5cb40, 0x1cf6, 0x6c781c0, 0xc010baf880, 0x0, 0x0, 0x0, ...)\n\t/Users/xuhuaiyu/Development/GOPATH/src/github.com/pingcap/tidb/planner/core/optimizer.go:140 +0x77\ngithub.com/pingcap/tidb/planner.optimize(0x6c23780, 0xc010d5b7d0, 0x6c7c880, 0xc00fc5cb40, 0x6c42060, 0xc01087fa00, 0x6c6eba0, 0xc010ae3a40, 0x0, 0x0, ...)\n\t/Users/xuhuaiyu/Development/GOPATH/src/github.com/pingcap/tidb/planner/optimize.go:289 +0x66c\ngithub.com/pingcap/tidb/planner.Optimize(0x6c23780, 0xc010d5b7d0, 0x6c7c880, 0xc00fc5cb40, 0x6c42060, 0xc01087fa00, 0x6c6eba0, 0xc010ae3a40, 0x0, 0x0, ...)\n\t/Users/xuhuaiyu/Development/GOPATH/src/github.com/pingcap/tidb/planner/optimize.go:125 +0x494\ngithub.com/pingcap/tidb/planner/core.(*PlanBuilder).buildExplain(0xc010bc1760, 0x6c23780, 0xc010d5b7d0, 0xc010b11e00, 0x100000001, 0xc0107783d0, 0x4055868, 0xf7ea041f7ca3)\n\t/Users/xuhuaiyu/Development/GOPATH/src/github.com/pingcap/tidb/planner/core/planbuilder.go:3525 +0x111\ngithub.com/pingcap/tidb/planner/core.(*PlanBuilder).Build(0xc010bc1760, 0x6c23780, 0xc010d5b7d0, 0x6c40b60, 0xc010b11e00, 0xc010bc1760, 0xc010a4bb80, 0x1, 0x1)\n\t/Users/xuhuaiyu/Development/GOPATH/src/github.com/pingcap/tidb/planner/core/planbuilder.go:610 +0xe0b\ngithub.com/pingcap/tidb/planner.optimize(0x6c23780, 0xc010d5b7d0, 0x6c7c880, 0xc00fc5cb40, 0x6c40b60, 0xc010b11e00, 0x6c6eba0, 0xc010ae3a40, 0x0, 0x0, ...)\n\t/Users/xuhuaiyu/Development/GOPATH/src/github.com/pingcap/tidb/planner/optimize.go:235 +0x1e9\ngithub.com/pingcap/tidb/planner.Optimize(0x6c23780, 0xc010d5b7d0, 0x6c7c880, 0xc00fc5cb40, 0x6c40b60, 0xc010b11e00, 0x6c6eba0, 0xc010ae3a40, 0x0, 0x0, ...)\n\t/Users/xuhuaiyu/Development/GOPATH/src/github.com/pingcap/tidb/planner/optimize.go:125 +0x494\ngithub.com/pingcap/tidb/executor.(*Compiler).Compile(0xc010778d60, 0x6c23780, 0xc010d5b7d0, 0x6c481e0, 0xc010b11e00, 0x0, 0x0, 0x0)\n\t/Users/xuhuaiyu/Development/GOPATH/src/github.com/pingcap/tidb/executor/compiler.go:62 +0x294\ngithub.com/pingcap/tidb/session.(*session).ExecuteStmt(0xc00fc5cb40, 0x6c23780, 0xc010d5b7d0, 0x6c481e0, 0xc010b11e00, 0x0, 0x0, 0x0, 0x0)\n\t/Users/xuhuaiyu/Development/GOPATH/src/github.com/pingcap/tidb/session/session.go:1409 +0x2c4\ngithub.com/pingcap/tidb/server.(*TiDBContext).ExecuteStmt(0xc00fbe7a70, 0x6c23780, 0xc010d5b7d0, 0x6c481e0, 0xc010b11e00, 0xc010dfc8c0, 0x6c23780, 0xc010d5b7d0, 0xc010779130)\n\t"]

@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
affects-5.0 This bug affects 5.0.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.

5 participants