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 for Key partitioned table when partitioning column is not the first column. #50206

Closed
mjonss opened this issue Jan 8, 2024 · 5 comments · Fixed by #50210
Assignees
Labels
affects-7.5 affects-7.6 report/community The community has encountered this bug. severity/major sig/sql-infra SIG: SQL Infra type/bug The issue is confirmed as a bug. type/regression

Comments

@mjonss
Copy link
Contributor

mjonss commented Jan 8, 2024

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

drop table if exists t;
create table t (b varchar(255), a int primary key nonclustered, key (b)) partition by key(a) partitions 3;
insert into t values ('Ab', 1),('abc',2),('BC',3),('AC',4),('BA',5),('cda',6);
analyze table t;
select * from t where a = 2;

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

Success

3. What did you see instead (Required)

tidb> create table t (b varchar(255), a int primary key nonclustered, key (b)) partition by key(a) partitions 3;
Query OK, 0 rows affected (0.13 sec)

tidb> insert into t values ('Ab', 1),('abc',2),('BC',3),('AC',4),('BA',5),('cda',6);
Query OK, 6 rows affected (0.02 sec)
Records: 6  Duplicates: 0  Warnings: 0

tidb> analyze table t;
Query OK, 0 rows affected, 6 warnings (0.29 sec)

tidb> select * from t where a = 2;
ERROR 1105 (HY000): runtime error: index out of range [1] with length 1

4. What is your TiDB version? (Required)

tidb_version(): Release Version: v7.5.0
Edition: Community
Git Commit Hash: 069631e2ecfedc000ffb92c67207bea81380f020
Git Branch: heads/refs/tags/v7.5.0
UTC Build Time: 2023-11-24 08:50:14
GoVersion: go1.21.3
Race Enabled: false
Check Table Before Drop: false
Store: tikv
@kennedy8312
Copy link

/type regression

@kennedy8312
Copy link

Regression Analysis
The issue didn't happen in v7.3.0.
`mysql> use test;
Database changed
mysql> drop table if exists t;
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> create table t (b varchar(255), a int primary key nonclustered, key (b)) partition by key(a) partitions 3;
Query OK, 0 rows affected (0.10 sec)

mysql> insert into t values ('Ab', 1),('abc',2),('BC',3),('AC',4),('BA',5),('cda',6);
Query OK, 6 rows affected (0.01 sec)
Records: 6 Duplicates: 0 Warnings: 0

mysql> analyze table t;
Query OK, 0 rows affected, 6 warnings (0.23 sec)

mysql> select * from t where a = 2;
+------+---+
| b | a |
+------+---+
| abc | 2 |
+------+---+
1 row in set (0.00 sec)

mysql>
mysql>
mysql> select tidb_version();
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tidb_version() |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Release Version: v7.3.0
Edition: Community
Git Commit Hash: 40b72e7
Git Branch: heads/refs/tags/v7.3.0
UTC Build Time: 2023-08-08 09:27:28
GoVersion: go1.20.7
Race Enabled: false
Check Table Before Drop: false
Store: tikv |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)The issue did happened in v7.4.0.mysql> use test;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> drop table if exists t;
Query OK, 0 rows affected (0.28 sec)

mysql> create table t (b varchar(255), a int primary key nonclustered, key (b)) partition by key(a) partitions 3;
Query OK, 0 rows affected (0.11 sec)

mysql> insert into t values ('Ab', 1),('abc',2),('BC',3),('AC',4),('BA',5),('cda',6);
Query OK, 6 rows affected (0.02 sec)
Records: 6 Duplicates: 0 Warnings: 0

mysql> analyze table t;
Query OK, 0 rows affected, 6 warnings (0.19 sec)

mysql> select * from t where a = 2;
ERROR 1105 (HY000): runtime error: index out of range [1] with length 1
mysql>
mysql> select tidb_version();
ERROR 2013 (HY000): Lost connection to MySQL server during query
No connection. Trying to reconnect...
Connection id: 3439329292
Current database: test

+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tidb_version() |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Release Version: v7.4.0
Edition: Community
Git Commit Hash: 38cb4f3
Git Branch: heads/refs/tags/v7.4.0
UTC Build Time: 2023-10-10 14:10:02
GoVersion: go1.21.0
Race Enabled: false
Check Table Before Drop: false
Store: tikv |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.02 sec)`

@kennedy8312
Copy link

Regression Analysis
PR caused this regression : 42907

@kennedy8312
Copy link

mysql --comments --host 127.0.0.1 --port 4000 -u root test < issue50206_testcase.sql
b a
abc 2
mysql --comments --host 127.0.0.1 --port 4000 -u root test -e "select tidb_version();"
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tidb_version() |
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Release Version: v7.4.0-alpha-139-ge8ca3d4e10-dirty
Edition: Community
Git Commit Hash: e8ca3d4
Git Branch: HEAD
UTC Build Time: 2024-01-10 09:38:56
GoVersion: go1.21.4
Race Enabled: false
Check Table Before Drop: false
Store: unistore |

mysql --comments --host 127.0.0.1 --port 4000 -u root test < issue50206_testcase.sql
ERROR 1105 (HY000) at line 5: runtime error: index out of range [1] with length 1
mysql --comments --host 127.0.0.1 --port 4000 -u root test -e "select tidb_version();"
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tidb_version() |
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Release Version: v7.4.0-alpha-140-g3e5c7512d5-dirty
Edition: Community
Git Commit Hash: 3e5c751
Git Branch: HEAD
UTC Build Time: 2024-01-10 09:42:00
GoVersion: go1.21.4
Race Enabled: false
Check Table Before Drop: false
Store: unistore |

@seiya-annie
Copy link

/found community

@ti-chi-bot ti-chi-bot bot added the report/community The community has encountered this bug. label Jun 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-7.5 affects-7.6 report/community The community has encountered this bug. severity/major sig/sql-infra SIG: SQL Infra type/bug The issue is confirmed as a bug. type/regression
Projects
None yet
4 participants