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

runtime error: index out of range [2] with length 1 #22850

Closed
Thearas opened this issue Feb 20, 2021 · 2 comments · Fixed by #23354
Closed

runtime error: index out of range [2] with length 1 #22850

Thearas opened this issue Feb 20, 2021 · 2 comments · Fixed by #23354
Assignees
Labels
severity/major sig/planner SIG: Planner type/bug The issue is confirmed as a bug.

Comments

@Thearas
Copy link

Thearas commented Feb 20, 2021

Bug Report

1. Minimal reproduce step (Required)

drop table if exists t1;
CREATE TABLE t1 (a int(11));
SELECT @v:=(SELECT 1 FROM t1 t2 LEFT JOIN t1 ON t1.a GROUP BY t1.a) FROM t1;

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

No panic.

3. What did you see instead (Required)

Panic:

[2021/02/20 18:31:16.184 +08:00] [ERROR] [conn.go:734] ["connection running loop panic"] [conn=5] [lastSQL="SELECT IF( @v:=LEAST((SELECT 1 FROM t1  t2 LEFT JOIN t1 ON (@v) GROUP BY t1.a), a), count(*), 1) FROM t1  GROUP BY a LIMIT 1"] [err="runtime error: index out of range [2] with length 1"] [stack="goroutine 982 [running]:\ngithub.com/pingcap/tidb/server.(*clientConn).Run.func1(0x3f8a0a0, 0xc001187950, 0xc000a2af00)\n\t/home/jenkins/agent/workspace/tidb_master/go/src/github.com/pingcap/tidb/server/conn.go:732 +0xee\npanic(0x3730fe0, 0xc00146e000)\n\t/usr/local/go/src/runtime/panic.go:679 +0x1b2\ngithub.com/pingcap/tidb/planner/core.(*expressionRewriter).toColumn(0xc0013c5380, 0xc0013af000)\n\t/home/jenkins/agent/workspace/tidb_master/go/src/github.com/pingcap/tidb/planner/core/expression_rewriter.go:1725 +0xfba\ngithub.com/pingcap/tidb/planner/core.(*expressionRewriter).Leave(0xc0013c5380, 0x3fa6ac0, 0xc0013af000, 0x3fa6ac0, 0xc0013af000, 0x203000)\n\t/home/jenkins/agent/workspace/tidb_master/go/src/github.com/pingcap/tidb/planner/core/expression_rewriter.go:1043 +0x1b42\ngithub.com/pingcap/parser/ast.(*ColumnName).Accept(0xc0013af000, 0x3f52260, 0xc0013c5380, 0x3fa6b20, 0xc0013c74d0, 0xc0009f4800)\n\t/home/jenkins/agent/workspace/tidb_master/go/pkg/mod/github.com/pingcap/parser@v0.0.0-20210203141130-32ef3e0e2e13/ast/expressions.go:527 +0x8a\ngithub.com/pingcap/parser/ast.(*ColumnNameExpr).Accept(0xc0013c74d0, 0x3f52260, 0xc0013c5380, 0xc0009f48c0, 0xc001452f50, 0x0)\n\t/home/jenkins/agent/workspace/tidb_master/go/pkg/mod/github.com/pingcap/parser@v0.0.0-20210203141130-32ef3e0e2e13/ast/expressions.go:589 +0x96\ngithub.com/pingcap/tidb/planner/core.(*PlanBuilder).rewriteExprNode(0xc001356a80, 0xc0013c5380, 0x3fc1e80, 0xc0013c74d0, 0xc0009f4801, 0x0, 0x0, 0x0, 0x0, 0x0, ...)\n\t/home/jenkins/agent/workspace/tidb_master/go/src/github.com/pingcap/tidb/planner/core/expression_rewriter.go:195 +0x8e\ngithub.com/pingcap/tidb/planner/core.(*PlanBuilder).rewriteWithPreprocess(0xc001356a80, 0x3f8a0a0, 0xc001400840, 0x3fc1e80, 0xc0013c74d0, 0x3fdd980, 0xc0009f48c0, 0x0, 0x0, 0x1b2f601, ...)\n\t/home/jenkins/agent/workspace/tidb_master/go/src/github.com/pingcap/tidb/planner/core/expression_rewriter.go:142 +0x163\ngithub.com/pingcap/tidb/planner/core.(*PlanBuilder).rewrite(0xc001356a80, 0x3f8a0a0, 0xc001400840, 0x3fc1e80, 0xc0013c74d0, 0x3fdd980, 0xc0009f48c0, 0x0, 0x1, 0x0, ...)\n\t/home/jenkins/agent/workspace/tidb_master/go/src/github.com/pingcap/tidb/planner/core/expression_rewriter.go:110 +0xb9\ngithub.com/pingcap/tidb/planner/core.(*PlanBuilder).resolveGbyExprs(0xc001356a80, 0x3f8a0a0, 0xc001400840, 0x3fdd980, 0xc0009f48c0, 0xc0014005d0, 0xc00145c068, 0x1, 0x1, 0x0, ...)\n\t/home/jenkins/agent/workspace/tidb_master/go/src/github.com/pingcap/tidb/planner/core/logical_plan_builder.go:3012 +0x347\ngithub.com/pingcap/tidb/planner/core.(*PlanBuilder).buildSelect(0xc001356a80, 0x3f8a0a0, 0xc001400840, 0xc001309900, 0x3fdd980, 0xc0009f48c0, 0x0, 0x0)\n\t/home/jenkins/agent/workspace/tidb_master/go/src/github.com/pingcap/tidb/planner/core/logical_plan_builder.go:3325 +0x1cce\ngithub.com/pingcap/tidb/planner/core.(*PlanBuilder).buildResultSetNode(0xc001356a80, 0x3f8a0a0, 0xc001400840, 0x3fa8ce0, 0xc001309900, 0x0, 0x0, 0xc001303750, 0x134eb1e)\n\t/home/jenkins/agent/workspace/tidb_master/go/src/github.com/pingcap/tidb/planner/core/logical_plan_builder.go:376 +0x974\ngithub.com/pingcap/tidb/planner/core.(*expressionRewriter).buildSubquery(0xc0013c52b0, 0x3f8a0a0, 0xc001400840, 0xc0013c7560, 0x0, 0x0, 0x0, 0x0)\n\t/home/jenkins/agent/workspace/tidb_master/go/src/github.com/pingcap/tidb/planner/core/expression_rewriter.go:325 +0x9e\ngithub.com/pingcap/tidb/planner/core.(*expressionRewriter).handleScalarSubquery(0xc0013c52b0, 0x3f8a0a0, 0xc001400840, 0xc0013c7560, 0x38, 0xc0002b1dd0, 0x203000)\n\t/home/jenkins/agent/workspace/tidb_master/go/src/github.com/pingcap/tidb/planner/core/expression_rewriter.go:947 +0x6a\ngithub.com/pingcap/tidb/planner/core.(*expressionRewriter).Enter(0xc0013c52b0, 0x3fa9280, 0xc0013c7560, 0xc000316d20, 0xc0013211e8, 0x2)\n\t/home/jenkins/agent/workspace/tidb_master/go/src/github.com/pingcap/tidb/planner/core/expression_rewriter.go:392 +0x91a\ngithub.com/pingcap/parser/ast.(*SubqueryExpr).Accept(0xc0013c7560, 0x3f52260, 0xc0013c52b0, 0x3fa79c0, 0xc0009b4fc0, 0xc0009b5000)\n\t/home/jenkins/agent/workspace/tidb_master/go/pkg/mod/github.com/pingcap/parser@v0."]

4. What is your TiDB version? (Required)

Release Version: v4.0.0-beta.2-2148-g381ac81f2-dirty
Edition: Community
Git Commit Hash: 381ac81f2df09093096c0bda4ba2c9118b759488
Git Branch: master
UTC Build Time: 2021-02-19 14:00:26
GoVersion: go1.13
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false
@Thearas Thearas added the type/bug The issue is confirmed as a bug. label Feb 20, 2021
@qw4990 qw4990 self-assigned this Feb 22, 2021
@qw4990
Copy link
Contributor

qw4990 commented Feb 22, 2021

Thanks for your feedback. I will fix it soon.

@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/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.

4 participants