In version 6.5.0, query error `ERROR 1105 (HY000): runtime error: index out of range [1] with length 0`

Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: 在6.5.0版本查询报错误ERROR 1105 (HY000): runtime error: index out of range [1] with length 0

| username: dba-kit

【TiDB Usage Environment】Production Environment
【TiDB Version】V6.5.0
The same SQL query works fine in version 6.1.2, but in version 6.5.0 it reports an error ERROR 1105 (HY000): runtime error: index out of range [1] with length 0. The error stack log is as follows:

[2023/01/04 09:31:37.291 +08:00] [ERROR] [index_lookup_join.go:484] ["innerWorker panicked"] [conn=5156021239990909561] [recover="runtime error: index out of range [1] with length 0"] [stack="github.com/pingcap/tidb/executor.(*innerWorker).run.func1
	/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/executor/index_lookup_join.go:484
runtime.gopanic
	/usr/local/go/src/runtime/panic.go:884
runtime.goPanicIndex
	/usr/local/go/src/runtime/panic.go:113
github.com/pingcap/tidb/util/chunk.setMutRowBytes
	/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/util/chunk/mutrow.go:335
github.com/pingcap/tidb/util/chunk.MutRow.SetDatum
	/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/util/chunk/mutrow.go:305
github.com/pingcap/tidb/util/chunk.MutRow.SetDatums
	/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/util/chunk/mutrow.go:288
github.com/pingcap/tidb/table/tables.(*partitionedTable).locateRangeColumnPartition.func1
	/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/table/tables/partition.go:1010
sort.Search
	/usr/local/go/src/sort/search.go:65
github.com/pingcap/tidb/table/tables.(*partitionedTable).locateRangeColumnPartition
	/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/table/tables/partition.go:1009
github.com/pingcap/tidb/table/tables.(*partitionedTable).locatePartition
	/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/table/tables/partition.go:991
github.com/pingcap/tidb/table/tables.(*partitionedTable).GetPartitionByRow
	/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/table/tables/partition.go:1159
github.com/pingcap/tidb/executor.(*dataReaderBuilder).buildTableReaderForIndexJoin
	/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/executor/builder.go:4169
github.com/pingcap/tidb/executor.(*dataReaderBuilder).buildExecutorForIndexJoinInternal
	/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/executor/builder.go:4064
github.com/pingcap/tidb/executor.(*dataReaderBuilder).buildExecutorForIndexJoin
	/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/executor/builder.go:4057
github.com/pingcap/tidb/executor.(*innerWorker).fetchInnerResults
	/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/executor/index_lookup_join.go:690
github.com/pingcap/tidb/executor.(*innerWorker).handleTask
	/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/executor/index_lookup_join.go:528
github.com/pingcap/tidb/executor.(*innerWorker).run
	/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/executor/index_lookup_join.go:502"]

PS: It feels like a new bug was introduced while fixing another bug

| username: dba-kit | Original post link

The same SQL query works fine after setting set tidb_partition_prune_mode='static';.

| username: dba-kit | Original post link

In the fixed PR, the function github.com/pingcap/tidb/executor.(*dataReaderBuilder).buildExecutorForIndexJoin was indeed modified, and this function is also present in the error path this time.

| username: WalterWj | Original post link

It should be a bug, you can file an issue.

| username: WalterWj | Original post link

Or you could go to the feedback section and see if anyone responds. :thinking:

| username: Billmay表妹 | Original post link

I have already reported it to the relevant teacher~

| username: tiancaiamao | Original post link

Do you have the table structure for the query? A minimal reproducible example would help with troubleshooting.

| username: mayjiang0203 | Original post link

Regarding the progress of this issue, please follow the issue below. We will fix it as soon as possible. Thank you for your feedback~

| username: dba-kit | Original post link

It’s not easy to provide a reproducible example for this. The original SQL involves join operations on multiple partitioned tables, and the data to be queried is quite extensive, so I can’t provide the table structure and the minimal reproducible example. However, it can indeed be consistently reproduced within the same cluster.

| username: system | Original post link

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.