tidb icon indicating copy to clipboard operation
tidb copied to clipboard

Runtime Error: index out of range

Open bajinsheng opened this issue 6 months ago • 6 comments

Bug Report

1. Minimal reproduce step (Required)

create table t0(c0 INT); 
create view v1 as select exists( select 6 from t0 union select c_0 from t0 ) c_2 from ( select 0 c_0 ) subq_0; 
create view v2 as select 7 c_1 from t0 where ( select c_2 from v1 ); 
create view v3 as select ( select c_2 from v1 ) c_3, ( select 7 from v2 ) c_4;
select c_4 from v3 where(c_4 = abs(c_3)); ERROR 1105 (HY000) at line 1: runtime error: index out of range [0] with length 0

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

No error

3. What did you see instead (Required)

4. What is your TiDB version? (Required)

tiup playground nightly --host 0.0.0.0 --kv 3 --tiflash 3

8.0.11-TiDB-v9.0.0-beta.1.pre-554-gb1a5536a64-dirty

bajinsheng avatar Jun 11 '25 14:06 bajinsheng

/label fuzz/sqlancer

bajinsheng avatar Jun 11 '25 14:06 bajinsheng

[wait_group_wrapper.go:198] ["panic in the wait group"] [recover="runtime error: index out of range [0] with length 0"] [stack="github.com/pingcap/tidb/pkg/util.(*WaitGroupWrapper).RunWithRecover.func1.1\n\t/workspace/source/tidb/pkg/util/wait_group_wrapper.go:198\nruntime.gopanic\n\t/root/go/pkg/mod/golang.org/[email protected]/src/runtime/panic.go:791\nruntime.goPanicIndex\n\t/root/go/pkg/mod/golang.org/[email protected]/src/runtime/panic.go:115\ngithub.com/pingcap/tidb/pkg/util/codec.SerializeKeys.func1\n\t/workspace/source/tidb/pkg/util/codec/codec.go:431\ngithub.com/pingcap/tidb/pkg/util/codec.SerializeKeys\n\t/workspace/source/tidb/pkg/util/codec/codec.go:443\ngithub.com/pingcap/tidb/pkg/executor/join.(*rowTableBuilder).processOneChunk\n\t/workspace/source/tidb/pkg/executor/join/row_table_builder.go:126\ngithub.com/pingcap/tidb/pkg/executor/join.(*BuildWorkerV2).processOneChunk\n\t/workspace/source/tidb/pkg/executor/join/hash_join_v2.go:551\ngithub.com/pingcap/tidb/pkg/executor/join.(*BuildWorkerV2).splitPartitionAndAppendToRowTableImpl\n\t/workspace/source/tidb/pkg/executor/join/hash_join_v2.go:571\ngithub.com/pingcap/tidb/pkg/executor/join.(*BuildWorkerV2).splitPartitionAndAppendToRowTable\n\t/workspace/source/tidb/pkg/executor/join/hash_join_v2.go:533\ngithub.com/pingcap/tidb/pkg/executor/join.(*HashJoinV2Exec).splitAndAppendToRowTable.func1\n\t/workspace/source/tidb/pkg/executor/join/hash_join_v2.go:1446\ngithub.com/pingcap/tidb/pkg/util.(*WaitGroupWrapper).RunWithRecover.func1\n\t/workspace/source/tidb/pkg/util/wait_group_wrapper.go:202"]

jebter avatar Jun 13 '25 06:06 jebter

It is good in v8.5. but it is bad in the master.

hawkingrei avatar Jun 14 '25 15:06 hawkingrei

It is caused by https://github.com/pingcap/tidb/pull/55821

hawkingrei avatar Jun 14 '25 15:06 hawkingrei

It seems to be a problem caused by the optimizer.

The log shows that nullVector in build worker is empty, which causes the panic. In fact, the corresponding column is a nullable column, but the HasNullableKey field in BuildWorkerV2 is initialized with false, which is decided by the passed-in parameter buildTypes which is the return type from the child executor.

xzhangxian1008 avatar Jun 17 '25 03:06 xzhangxian1008

@hawkingrei PTAL

solotzg avatar Jun 17 '25 06:06 solotzg

🔗 Related Issues

I found some similar issues that might be related, please check them at first, if you think this issue is similar to them, please close this issue.

  1. ✨ Similar https://github.com/pingcap/tidb/issues/7311 (match via title)

  2. ✨ Similar https://github.com/pingcap/tidb/issues/12448 (match via title)

  3. ✨ Similar https://github.com/pingcap/tidb/issues/19226 (match via body)

  4. ✨ Similar https://github.com/pingcap/tidb/issues/43256 (match via body)

  5. ✨ Similar https://github.com/pingcap/tidb/issues/22199 (match via body)


This comment was automatically generated based on semantic similarity analysis.