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

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

Closed
ChenPeng2013 opened this issue Nov 9, 2021 · 9 comments · Fixed by #29905
Closed

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

ChenPeng2013 opened this issue Nov 9, 2021 · 9 comments · Fixed by #29905
Assignees
Labels
severity/moderate sig/planner SIG: Planner type/bug The issue is confirmed as a bug.

Comments

@ChenPeng2013
Copy link
Contributor

ChenPeng2013 commented Nov 9, 2021

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

new_collations_enabled_on_first_bootstrap = true

use test;
drop table if exists PK_MULTI_COL_3623;
CREATE TABLE `PK_MULTI_COL_3623` (
  `COL1` varbinary(10) NOT NULL,
  `COL2` char(10) COLLATE utf8_general_ci NOT NULL,
  `COL3` tinyint(4) NOT NULL,
  PRIMARY KEY (`COL1`(5),`COL2`,`COL3`) /*T![clustered_index] NONCLUSTERED */,
  UNIQUE KEY `UIDXM` (`COL1`(5),`COL2`),
  UNIQUE KEY `UIDX` (`COL2`),
  KEY `IDX3` (`COL3`),
  KEY `IDXM` (`COL3`,`COL2`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;

explain select * from PK_MULTI_COL_3623 where col2 != 0x9ABA8F2DA0D0CDF03A;
explain select * from PK_MULTI_COL_3623 where col2 != 0x9ABA8F2DA0D0CDF03A87;

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

mysql> explain select * from PK_MULTI_COL_3623 where col2 != 0x9ABA8F2DA0D0CDF03A;
+-------------------------+----------+-----------+-------------------------+---------------------------------------------------------+
| id                      | estRows  | task      | access object           | operator info                                           |
+-------------------------+----------+-----------+-------------------------+---------------------------------------------------------+
| TableReader_7           | 6656.67  | root      |                         | data:Selection_6                                        |
| └─Selection_6           | 6656.67  | cop[tikv] |                         | ne(test.pk_multi_col_3623.col2, "0x9aba8f2da0d0cdf03a") |
|   └─TableFullScan_5     | 10000.00 | cop[tikv] | table:PK_MULTI_COL_3623 | keep order:false, stats:pseudo                          |
+-------------------------+----------+-----------+-------------------------+---------------------------------------------------------+
3 rows in set, 1 warning (0.00 sec)

mysql> explain select * from PK_MULTI_COL_3623 where col2 != 0x9ABA8F2DA0D0CDF03A87;

+-------------------------+----------+-----------+-------------------------+---------------------------------------------------------+
| id                      | estRows  | task      | access object           | operator info                                           |
+-------------------------+----------+-----------+-------------------------+---------------------------------------------------------+
| TableReader_7           | 6656.67  | root      |                         | data:Selection_6                                        |
| └─Selection_6           | 6656.67  | cop[tikv] |                         | ne(test.pk_multi_col_3623.col2, "0x9aba8f2da0d0cdf03a87") |
|   └─TableFullScan_5     | 10000.00 | cop[tikv] | table:PK_MULTI_COL_3623 | keep order:false, stats:pseudo                          |
+-------------------------+----------+-----------+-------------------------+---------------------------------------------------------+
3 rows in set, 1 warning (0.00 sec)

3. What did you see instead (Required)

mysql> explain select * from PK_MULTI_COL_3623 where col2 != 0x9ABA8F2DA0D0CDF03A;
+-------------------------+----------+-----------+-------------------------+---------------------------------------------------------+
| id                      | estRows  | task      | access object           | operator info                                           |
+-------------------------+----------+-----------+-------------------------+---------------------------------------------------------+
| TableReader_7           | 6656.67  | root      |                         | data:Selection_6                                        |
| └─Selection_6           | 6656.67  | cop[tikv] |                         | ne(test.pk_multi_col_3623.col2, "0x9aba8f2da0d0cdf03a") |
|   └─TableFullScan_5     | 10000.00 | cop[tikv] | table:PK_MULTI_COL_3623 | keep order:false, stats:pseudo                          |
+-------------------------+----------+-----------+-------------------------+---------------------------------------------------------+
3 rows in set, 1 warning (0.00 sec)

mysql> explain select * from PK_MULTI_COL_3623 where col2 != 0x9ABA8F2DA0D0CDF03A87;
ERROR 1105 (HY000): runtime error: index out of range [10] with length 10

4. What is your TiDB version? (Required)

Release Version: v5.4.0-alpha-49-g49d995d57
Edition: Community
Git Commit Hash: 49d995d577f64b79168a145cb5be45151ebb557a
Git Branch: master
UTC Build Time: 2021-11-08 10:12:15
GoVersion: go1.16.4
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false
@ChenPeng2013 ChenPeng2013 added type/bug The issue is confirmed as a bug. sig/sql-infra SIG: SQL Infra severity/moderate labels Nov 9, 2021
@sylzd sylzd removed their assignment Nov 9, 2021
@sylzd
Copy link
Contributor

sylzd commented Nov 9, 2021

cannot reproduce at master branch~~

@ChenPeng2013 ChenPeng2013 added sig/planner SIG: Planner and removed sig/sql-infra SIG: SQL Infra labels Nov 9, 2021
@chrysan
Copy link
Contributor

chrysan commented Nov 10, 2021

@ChenPeng2013 can you provide stack trace of the error?

@ChenPeng2013
Copy link
Contributor Author

\ngithub.com/pingcap/tidb/server.(*clientConn).Run.func1(0x42bdd30, 0xc001e07290, 0xc001535680)\n\t/home/jenkins/agent/workspace/build_tidb_multi_branch_master/go/src/github.com/pingcap/tidb/server/conn.go:969 +0xf5\npanic(0x3b450c0, 0xc0011b7d88)\n\t/usr/local/go/src/runtime/panic.go:965 +0x1b9\ngithub.com/pingcap/tidb/util/collate.decodeRune(0xc0011b7c68, 0xa, 0x9, 0x3a, 0x9)\n\t/home/jenkins/agent/workspace/build_tidb_multi_branch_master/go/src/github.com/pingcap/tidb/util/collate/collate.go:279 +0x17f\ngithub.com/pingcap/tidb/util/collate.(*generalCICollator).Compare(0x6189f88, 0xc0011b7c68, 0xa, 0xc0011b7c68, 0xa, 0xc000100400)\n\t/home/jenkins/agent/workspace/build_tidb_multi_branch_master/go/src/github.com/pingcap/tidb/util/collate/general_ci.go:31 +0x105\ngithub.com/pingcap/tidb/types.CompareString(0xc0011b7c68, 0xa, 0xc0011b7c68, 0xa, 0xc001536f70, 0xf, 0x0)\n\t/home/jenkins/agent/workspace/build_tidb_multi_branch_master/go/src/github.com/pingcap/tidb/types/compare.go:119 +0x71\ngithub.com/pingcap/tidb/types.(*Datum).compareString(0xc0025056d0, 0xc001fb3ec8, 0xc0011b7c68, 0xa, 0xc001536f70, 0xf, 0xf, 0x5, 0x0)\n\t/home/jenkins/agent/workspace/build_tidb_multi_branch_master/go/src/github.com/pingcap/tidb/types/datum.go:683 +0x495\ngithub.com/pingcap/tidb/types.(*Datum).CompareDatum(0xc0025056d0, 0xc001fb3ec8, 0xc00200d6a8, 0x5, 0x0, 0xc001536f70)\n\t/home/jenkins/agent/workspace/build_tidb_multi_branch_master/go/src/github.com/pingcap/tidb/types/datum.go:583 +0x245\ngithub.com/pingcap/tidb/util/ranger.convertPoint(0xc001fb3ec8, 0xc0025056d0, 0xc001807740, 0xc002505680, 0x0, 0x0)\n\t/home/jenkins/agent/workspace/build_tidb_multi_branch_master/go/src/github.com/pingcap/tidb/util/ranger/ranger.go:119 +0x194\ngithub.com/pingcap/tidb/util/ranger.points2Ranges(0xc001fb3ec8, 0xc002506e70, 0x4, 0x6, 0xc001807740, 0x4, 0x4, 0x0, 0xc002506e70, 0x4)\n\t/home/jenkins/agent/workspace/build_tidb_multi_branch_master/go/src/github.com/pingcap/tidb/util/ranger/ranger.go:63 +0x17e\ngithub.com/pingcap/tidb/util/ranger.(*rangeDetacher).buildCNFIndexRange(0xc00200dce8, 0xc0021b3240, 0x2, 0x2, 0x0, 0xc0021b3230, 0x1, 0x1, 0x1, 0x0, ...)\n\t/home/jenkins/agent/workspace/build_tidb_multi_branch_master/go/src/github.com/pingcap/tidb/util/ranger/ranger.go:376 +0x72a\ngithub.com/pingcap/tidb/util/ranger.(*rangeDetacher).detachCNFCondAndBuildRangeForIndex(0xc00200dce8, 0xc0021b30f0, 0x1, 0x1, 0xc0017d9510, 0x1, 0x1, 0xc0017d9501, 0x7ff38ad3a5b8, 0x238af9c, ...)\n\t/home/jenkins/agent/workspace/build_tidb_multi_branch_master/go/src/github.com/pingcap/tidb/util/ranger/detacher.go:367 +0x13c5\ngithub.com/pingcap/tidb/util/ranger.(*rangeDetacher).detachCondAndBuildRangeForCols(0xc00200dce8, 0x1, 0x0, 0x1)\n\t/home/jenkins/agent/workspace/build_tidb_multi_branch_master/go/src/github.com/pingcap/tidb/util/ranger/detacher.go:791 +0x225\ngithub.com/pingcap/tidb/util/ranger.DetachCondAndBuildRangeForIndex(0x43080d8, 0xc001fa6600, 0xc0021b30f0, 0x1, 0x1, 0xc0017d9500, 0x1, 0x1, 0xc0015f0ec0, 0x1, ...)\n\t/home/jenkins/agent/workspace/build_tidb_multi_branch_master/go/src/github.com/pingcap/tidb/util/ranger/detacher.go:756 +0xf5\ngithub.com/pingcap/tidb/planner/core.(*DataSource).fillIndexPath(0xc000bd2a00, 0xc000b0b680, 0xc0021b30f0, 0x1, 0x1, 0x0, 0x0)\n\t/home/jenkins/agent/workspace/build_tidb_multi_branch_master/go/src/github.com/pingcap/tidb/planner/core/logical_plans.go:871 +0x53f\ngithub.com/pingcap/tidb/planner/core.(*DataSource).DeriveStats(0xc000bd2a00, 0x6189f88, 0x0, 0x0, 0xc002504410, 0x6189f88, 0x0, 0x0, 0x0, 0x0, ...)\n\t/home/jenkins/agent/workspace/build_tidb_multi_branch_master/go/src/github.com/pingcap/tidb/planner/core/stats.go:399 +0x145\ngithub.com/pingcap/tidb/planner/core.(*baseLogicalPlan).recursiveDeriveStats(0xc000bd2a20, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)\n\t/home/jenkins/agent/workspace/build_tidb_multi_branch_master/go/src/github.com/pingcap/tidb/planner/core/stats.go:131 +0x325\ngithub.com/pingcap/tidb/planner/core.(*baseLogicalPlan).recursiveDeriveStats(0xc002407980, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)\n\t/home/jenkins/agent/workspace/build_tidb_multi_b"

@ChenPeng2013
Copy link
Contributor Author

cannot reproduce at master branch~~

Did you use tikv to reproduce?

@AilinKid
Copy link
Contributor

AilinKid commented Nov 12, 2021

cannot reproduce at master nightly branch and hash 49d995d577f64b79168a145cb5be45151ebb557a, using tikv

Any special variables and sql_mode have you set up?

@ChenPeng2013
Copy link
Contributor Author

ChenPeng2013 commented Nov 15, 2021

cannot reproduce at master nightly branch and hash 49d995d577f64b79168a145cb5be45151ebb557a, using tikv

Any special variables and sql_mode have you set up?

I forget to add the step "new_collations_enabled_on_first_bootstrap: true"

@AilinKid
Copy link
Contributor

AilinKid commented Nov 15, 2021

got it~
panic location:
image

the cases comes from that decodeRune will take the string as valid utf8mb4-bin for granted while it's not in this cases

The final 0x87 should be reported as ERROR 3854 (HY000): Cannot convert string '\x87' from binary to utf8mb4

@AilinKid
Copy link
Contributor

AilinKid commented Nov 15, 2021

Actually it's tracked already: #29029 (jiwei says it will not be merged due some reasons, he will write a new one)

@github-actions
Copy link

Please check whether the issue should be labeled with 'affects-x.y' or 'fixes-x.y.z', and then remove 'needs-more-info' label.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
severity/moderate 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