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

partition table prune cause panic #35832

Closed
leonirvanel opened this issue Jun 30, 2022 · 7 comments
Closed

partition table prune cause panic #35832

leonirvanel opened this issue Jun 30, 2022 · 7 comments
Assignees
Labels
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. affects-5.4 This bug affects 5.4.x versions. affects-6.0 affects-6.1 may-affects-4.0 This bug maybe affects 4.0.x versions. may-affects-5.0 This bug maybe affects 5.0.x versions. severity/major sig/planner SIG: Planner type/bug This issue is a bug.

Comments

@leonirvanel
Copy link

leonirvanel commented Jun 30, 2022

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

1.1 prepare table
CREATE TABLE t_panic (
d int(11) DEFAULT NULL,
i varchar(10) DEFAULT NULL,
m varchar(10) DEFAULT NULL,
v int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
PARTITION BY RANGE (d)
(PARTITION p20220601 VALUES LESS THAN (20220602),
PARTITION p20220602 VALUES LESS THAN (20220603),
PARTITION p20220603 VALUES LESS THAN (20220604));

1.2 execute query
select d, m, sum(v) from t_panic where d = 20220604 group by m;

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

Empty set (0.01 sec)

3. What did you see instead (Required)

ERROR 1105 (HY000): runtime error: index out of range [3] with length 3

4. What is your TiDB version? (Required)

5.7.25-TiDB-v5.4.0
5.7.25-TiDB-v5.1.4

@leonirvanel leonirvanel added the type/bug This issue is a bug. label Jun 30, 2022
@ChenPeng2013 ChenPeng2013 added sig/planner SIG: Planner severity/major 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. affects-5.4 This bug affects 5.4.x versions. affects-6.0 affects-6.1 labels Jun 30, 2022
@ti-chi-bot ti-chi-bot added may-affects-4.0 This bug maybe affects 4.0.x versions. may-affects-5.0 This bug maybe affects 5.0.x versions. labels Jun 30, 2022
@chrysan
Copy link
Contributor

chrysan commented Jun 30, 2022

Can you provide the panic stack trace?

@leonirvanel
Copy link
Author

[conn.go:801] ["connection running loop panic"] [conn=7238699] [lastSQL="select d, m, sum(v) from t_panic where d = 20220604 group by m"] [err="runtime error: index out of range [3] with length 3"] [stack="goroutine 42165225680 [running]:\ngithub.com/pingcap/tidb/server.(*clientConn).Run.func1(0x3c187d8, 0xc1573e2ab0, 0xc229f94500)\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/server/conn.go:799 +0xf5\npanic(0x3555700, 0xc1b4609aa0)\n\t/usr/local/go/src/runtime/panic.go:965 +0x1b9\ngithub.com/pingcap/tidb/planner/core.(*partitionProcessor).pruneRangePartition(0x57eb7a0, 0x3c58130, 0xc0af7c6000, 0xc0e1d717c0, 0x3c4c498, 0xc12dca06e0, 0xc1f3271340, 0x1, 0x1, 0xc18e2ff180, ...)\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/planner/core/rule_partition_processor.go:856 +0xa6f\ngithub.com/pingcap/tidb/planner/core.(*partitionProcessor).processRangePartition(0x57eb7a0, 0xc1e756e000, 0xc0e1d717c0, 0xc03d474a00, 0xc1f3271300, 0x3c806a0, 0xc03d474a00)\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/planner/core/rule_partition_processor.go:869 +0x12a\ngithub.com/pingcap/tidb/planner/core.(*partitionProcessor).prune(0x57eb7a0, 0xc1e756e000, 0xc257f9fc78, 0x1119465, 0xc1f3271350, 0x0)\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/planner/core/rule_partition_processor.go:627 +0x2e5\ngithub.com/pingcap/tidb/planner/core.(*partitionProcessor).rewriteDataSource(0x57eb7a0, 0x3c55390, 0xc1e756e000, 0x1, 0xc1e756e000, 0x0, 0x0)\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/planner/core/rule_partition_processor.go:65 +0x8a\ngithub.com/pingcap/tidb/planner/core.(*partitionProcessor).rewriteDataSource(0x57eb7a0, 0x3c55490, 0xc0c1338500, 0x1, 0x264dac5, 0xc036f26540, 0xc18e2ffb80)\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/planner/core/rule_partition_processor.go:93 +0x153\ngithub.com/pingcap/tidb/planner/core.(*partitionProcessor).rewriteDataSource(0x57eb7a0, 0x3c55f90, 0xc23f453420, 0x57ee140, 0x0, 0x34a49c0, 0xc001114930)\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/planner/core/rule_partition_processor.go:93 +0x153\ngithub.com/pingcap/tidb/planner/core.(*partitionProcessor).optimize(0x57eb7a0, 0x3c187d8, 0xc091e60150, 0x3c55f90, 0xc23f453420, 0x3c55f90, 0xc23f453420, 0x0, 0x0)\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/planner/core/rule_partition_processor.go:58 +0x3f\ngithub.com/pingcap/tidb/planner/core.logicalOptimize(0x3c187d8, 0xc091e60150, 0x5dea, 0x3c55f90, 0xc23f453420, 0x324a400900000000, 0x62bd0033, 0xc257fa0408, 0x1161166)\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/planner/core/optimizer.go:243 +0x11b\ngithub.com/pingcap/tidb/planner/core.DoOptimize(0x3c187d8, 0xc091e60150, 0x3c58130, 0xc0af7c6000, 0x5dea, 0x3c55f90, 0xc23f453420, 0x0, 0x0, 0x0, ...)\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/planner/core/optimizer.go:152 +0xb8\ngithub.com/pingcap/tidb/planner.optimize(0x3c187d8, 0xc091e60150, 0x3c58130, 0xc0af7c6000, 0x3c2daf8, 0xc25765ca50, 0x3c4eea8, 0xc0a7685540, 0x0, 0x0, ...)\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/planner/optimize.go:288 +0x7ab\ngithub.com/pingcap/tidb/planner.Optimize(0x3c187d8, 0xc091e60150, 0x3c58130, 0xc0af7c6000, 0x3c2daf8, 0xc25765ca50, 0x3c4eea8, 0xc0a7685540, 0x0, 0x0, ...)\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/planner/optimize.go:124 +0x509\ngithub.com/pingcap/tidb/executor.(*Compiler).Compile(0xc038502ce0, 0x3c187d8, 0xc091e60150, 0x3c32d88, 0xc25765ca50, 0x0, 0x0, 0x0)\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/executor/compiler.go:63 +0x30d\ngithub.com/pingcap/tidb/session.(*session).ExecuteStmt(0xc0af7c6000, 0x3c187d8, 0xc091e60150, 0x3c32d88, 0xc25765ca50, 0x0, 0x0, 0x0, 0x0)\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/session/session.go:1510 +0x4c9\ngithub.com/pingcap/tidb/server.(*TiDBContext).ExecuteStmt(0xc4f2cb8b70, 0x3c187d8, 0xc091e60150, 0x3c32d88, 0xc25765ca50, 0xc0d9584220, 0x3c187d8, 0xc091e60150, 0x0)\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/ti"]

@leonirvanel
Copy link
Author

how to fix it ? @chrysan

@chrysan
Copy link
Contributor

chrysan commented Jul 6, 2022

@leonirvanel which version is this stack trace from? v5.4.0 or v5.1.4?

@leonirvanel
Copy link
Author

V5.1.4

@time-and-fate
Copy link
Member

This issue is the same as #35181 and has been fixed by #35298 on the master branch.
It will be fixed in the next major release.
For other release branches, it may be fixed in the next minor release at the earliest, but I'm not sure when would be the next release.

@time-and-fate
Copy link
Member

Closing this issue since it's a duplicate bug. Feel free to reopen it if you have further questions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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. affects-5.4 This bug affects 5.4.x versions. affects-6.0 affects-6.1 may-affects-4.0 This bug maybe affects 4.0.x versions. may-affects-5.0 This bug maybe affects 5.0.x versions. severity/major sig/planner SIG: Planner type/bug This issue is a bug.
Projects
None yet
Development

No branches or pull requests

5 participants