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

【 TiDB 使用环境】生产环境
【 TiDB 版本】V6.5.0
同一个SQL在6.1.2版本是正常,在6.5.0版本查询报错误ERROR 1105 (HY000): runtime error: index out of range [1] with length 0,错误的堆栈日志为:

[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: 感觉是解决另外一个BUG时引入的新BUG。。。

同样的SQL,在set tidb_partition_prune_mode='static';后,查询就正常了。

修复的PR里,确实修改了github.com/pingcap/tidb/executor.(*dataReaderBuilder).buildExecutorForIndexJoin 这个函数,这次报错的路径上也有这个函数

应该是 bug,可以提个 issue

或者去反馈区反馈下 看看有没有人管 :thinking:

已经反馈给相关的老师~

1 Like

有查询的 query 的表结构不? 最小可复现的例子会方便排查

关于这个问题的进展请关注下面的 issue,我们会尽快修复,感谢反馈~
https://github.com/pingcap/tidb/issues/40299

这个不太好给出可复现例子,原始SQL涉及多个分区表的join操作,要查询数据也比较多,所以表结构和最小可复现例子还给不出来。不过在同一个集群中,确实可以稳定复现的