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

TiDB produces different results for SELECT statements (runtime error: index out of range [0] with length 0) #38209

Open
JZuming opened this issue Sep 27, 2022 · 0 comments
Labels
affects-5.1 This bug affects 5.1.x versions. affects-5.2 This bug affects 5.2.x versions. affects-5.3 This bug affects 5.3.x versions. affects-5.4 This bug affects 5.4.x versions. affects-6.0 affects-6.1 affects-6.2 affects-6.3 affects-6.4 affects-6.5 affects-6.6 affects-7.0 affects-7.1 affects-7.5 affects-8.1 severity/major sig/execution SIG execution type/bug The issue is confirmed as a bug.

Comments

@JZuming
Copy link

JZuming commented Sep 27, 2022

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

Setup the environment:

tiup playground --db.binpath /path/to/latest/tidb-server &
mysql -h "127.0.0.1" -u root -P 4000 -D testdb < mysql_bk.sql

mysql_bk.sql: mysql_bk.txt

Testcase 1

mysql -h "127.0.0.1" -u root -P 4000 -D testdb

mysql> update t_smmcv set wkey = 501;
mysql> select *
from
  t_kb1xh
where 100 <= case when t_kb1xh.c_bihued = (
            select distinct
                  '1kkruc' as c0
                from
                  t_smmcv as ref_13
              ) then 101 else 57 end;

Testcase 2

mysql -h "127.0.0.1" -u root -P 4000 -D testdb

mysql> start transaction;
mysql> update t_smmcv set wkey = 501;
mysql> select *
from
  t_kb1xh
where 100 <= case when t_kb1xh.c_bihued = (
            select distinct
                  '1kkruc' as c0
                from
                  t_smmcv as ref_13
              ) then 101 else 57 end;
mysql> commit;

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

The execution result of SELECT statements in Testcase 1 and Testcase 2 are the same.

3. What did you see instead (Required)

Output of SELECT statement in Testcase 1

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

Output of SELECT statement in Testcase 2

Empty set (0.01 sec)

Their results are different.

Information of tidb.log when test case 1 triggers runtime errors

[2022/09/27 21:12:01.779 +00:00] [INFO] [conn.go:1137] 
["command dispatched failed"] 
[conn=5830617803119407401] 
[connInfo="id:5830617803119407401, addr:127.0.0.1:56480 status:10, collation:latin1_swedish_ci, user:root"]
[command=Query] [status="inTxn:0, autocommit:1"]
[sql="select *from  t_kb1xhwhere 100 <= case when t_kb1xh.c_bihued = (            select distinct                  '1kkruc' as c0                from                  t_smmcv as ref_13              ) then 101 else 57 end"] 
[txn_mode=PESSIMISTIC] [timestamp=436289698969944066] 
[err="runtime error: index out of range [0] with length 0
github.com/pingcap/tidb/executor.recoveryHashAgg
        /home/zuming/tidb/executor/aggregate.go:451
github.com/pingcap/tidb/executor.(*HashAggPartialWorker).run.func1
        /home/zuming/tidb/executor/aggregate.go:460
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.(*Column).GetString
        /home/zuming/tidb/util/chunk/column.go:577
github.com/pingcap/tidb/util/chunk.Row.GetString
        /home/zuming/tidb/util/chunk/row.go:72
github.com/pingcap/tidb/expression.(*Column).EvalString
        /home/zuming/tidb/expression/column.go:434
github.com/pingcap/tidb/executor/aggfuncs.(*firstRow4String).UpdatePartialResult
        /home/zuming/tidb/executor/aggfuncs/func_first_row.go:277
github.com/pingcap/tidb/executor.(*HashAggPartialWorker).updatePartialResult
        /home/zuming/tidb/executor/aggregate.go:520
github.com/pingcap/tidb/executor.(*HashAggPartialWorker).run
        /home/zuming/tidb/executor/aggregate.go:481
runtime.goexit
        /usr/local/go/src/runtime/asm_amd64.s:1594"]

4. What is your TiDB version? (Required)

Release Version: v6.3.0-20220913
Edition: Community
Git Commit Hash: 95e09ba33c0bdb629c4d4a7a31a2e4bc1212ad2a
Git Branch: HEAD
UTC Build Time: 2022-09-24 12:55:50
GoVersion: go1.19.1
Race Enabled: false
TiKV Min Version: 6.2.0-alpha
Check Table Before Drop: false
Store: tikv
@JZuming JZuming added the type/bug The issue is confirmed as a bug. label Sep 27, 2022
@aytrack aytrack added sig/execution SIG execution severity/major affects-5.1 This bug affects 5.1.x versions. affects-5.2 This bug affects 5.2.x versions. affects-5.3 This bug affects 5.3.x versions. affects-5.4 This bug affects 5.4.x versions. affects-6.0 affects-6.1 affects-6.2 affects-6.3 labels Sep 28, 2022
@ti-chi-bot ti-chi-bot added may-affects-4.0 This bug maybe affects 4.0.x versions. may-affects-5.0 This bug maybe affects 5.0.x versions. labels Sep 28, 2022
@aytrack aytrack removed may-affects-4.0 This bug maybe affects 4.0.x versions. may-affects-5.0 This bug maybe affects 5.0.x versions. labels Sep 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-5.1 This bug affects 5.1.x versions. affects-5.2 This bug affects 5.2.x versions. affects-5.3 This bug affects 5.3.x versions. affects-5.4 This bug affects 5.4.x versions. affects-6.0 affects-6.1 affects-6.2 affects-6.3 affects-6.4 affects-6.5 affects-6.6 affects-7.0 affects-7.1 affects-7.5 affects-8.1 severity/major sig/execution SIG execution type/bug The issue is confirmed as a bug.
Projects
None yet
Development

No branches or pull requests

4 participants