Skip to content

TiDB crashes when trying to run SHOW ERRORS statement #46962

@SteveLeungYL

Description

@SteveLeungYL

Bug Report

1. Minimal reproduce step (Required)

  1. Compile the TiDB using the source repository: link
  2. Check out with the latest master version: 1159bc8.
  3. Compile the TiDB server using go1.21.0. Use make in the repo root directory.
  4. Launch TiDB server using command:
./tidb-server -P 8000 -socket /tmp/mysql_0.sql -path $(pwd)/db_data
  1. Connect to the server using mysql client:
mysql -h 127.0.0.1 -P 8000 -u root --socket /tmp/mysql_0.sql
  1. Input the PoC Query to trigger the crash of the server.
drop database if exists test;
create database test;
use test;
SHOW ERRORS WHERE TRUE = ALL ( SELECT TRUE GROUP BY 1 LIMIT 1 ) IS NULL IS NOT NULL;

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

The TiDB Server should continue running.

3. What did you see instead (Required)

The TiDB-server crashes and then returns error:

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

Here is a more detailed stack trace from the latest master version (1159bc8):

github.com/pingcap/tidb/server.(*clientConn).Run.func1
\t/home/tidb/go_projects/src/github.com/tidb/tidb/server/conn.go:970
runtime.gopanic
\t/usr/local/go/src/runtime/panic.go:914
github.com/pingcap/tidb/executor.(*Compiler).Compile.func1
\t/home/tidb/go_projects/src/github.com/tidb/tidb/executor/compiler.go:54
runtime.gopanic
\t/usr/local/go/src/runtime/panic.go:914
runtime.goPanicIndex
\t/usr/local/go/src/runtime/panic.go:114
github.com/pingcap/tidb/planner/core.(*LogicalAggregation).IsPartialModeAgg
\t/home/tidb/go_projects/src/github.com/tidb/tidb/planner/core/logical_plans.go:1136
github.com/pingcap/tidb/planner/core.(*LogicalAggregation).BuildKeyInfo
\t/home/tidb/go_projects/src/github.com/tidb/tidb/planner/core/rule_build_key_info.go:47
github.com/pingcap/tidb/planner/core.buildKeyInfo
\t/home/tidb/go_projects/src/github.com/tidb/tidb/planner/core/rule_build_key_info.go:42
github.com/pingcap/tidb/planner/core.buildKeyInfo
\t/home/tidb/go_projects/src/github.com/tidb/tidb/planner/core/rule_build_key_info.go:36
github.com/pingcap/tidb/planner/core.buildKeyInfo
\t/home/tidb/go_projects/src/github.com/tidb/tidb/planner/core/rule_build_key_info.go:36
github.com/pingcap/tidb/planner/core.buildKeyInfo
\t/home/tidb/go_projects/src/github.com/tidb/tidb/planner/core/rule_build_key_info.go:36
github.com/pingcap/tidb/planner/core.buildKeyInfo
\t/home/tidb/go_projects/src/github.com/tidb/tidb/planner/core/rule_build_key_info.go:36
github.com/pingcap/tidb/planner/core.buildKeyInfo
\t/home/tidb/go_projects/src/github.com/tidb/tidb/planner/core/rule_build_key_info.go:36
github.com/pingcap/tidb/planner/core.buildKeyInfo
\t/home/tidb/go_projects/src/github.com/tidb/tidb/planner/core/rule_build_key_info.go:36
github.com/pingcap/tidb/planner/core.buildKeyInfo
\t/home/tidb/go_projects/src/github.com/tidb/tidb/planner/core/rule_build_key_info.go:36
github.com/pingcap/tidb/planner/core.buildKeyInfo
\t/home/tidb/go_projects/src/github.com/tidb/tidb/planner/core/rule_build_key_info.go:36
github.com/pingcap/tidb/planner/core.buildKeyInfo
\t/home/tidb/go_projects/src/github.com/tidb/tidb/planner/core/rule_build_key_info.go:36
github.com/pingcap/tidb/planner/core.(*buildKeySolver).optimize
\t/home/tidb/go_projects/src/github.com/tidb/tidb/planner/core/rule_build_key_info.go:29
github.com/pingcap/tidb/planner/core.logicalOptimize
\t/home/tidb/go_projects/src/github.com/tidb/tidb/planner/core/optimizer.go:1141
github.com/pingcap/tidb/planner/core.DoOptimizeAndLogicAsRet
\t/home/tidb/go_projects/src/github.com/tidb/tidb/planner/core/optimizer.go:305
github.com/pingcap/tidb/planner/core.DoOptimize
\t/home/tidb/go_projects/src/github.com/tidb/tidb/planner/core/optimizer.go:342
github.com/pingcap/tidb/planner.optimize
\t/home/tidb/go_projects/src/github.com/tidb/tidb/planner/optimize.go:525
github.com/pingcap/tidb/planner.Optimize
\t/home/tidb/go_projects/src/github.com/tidb/tidb/planner/optimize.go:348
github.com/pingcap/tidb/executor.(*Compiler).Compile
\t/home/tidb/go_projects/src/github.com/tidb/tidb/executor/compiler.go:98
github.com/pingcap/tidb/session.(*session).ExecuteStmt
\t/home/tidb/go_projects/src/github.com/tidb/tidb/session/session.go:2211
github.com/pingcap/tidb/server.(*TiDBContext).ExecuteStmt
\t/home/tidb/go_projects/src/github.com/tidb/tidb/server/driver_tidb.go:292
github.com/pingcap/tidb/server.(*clientConn).handleStmt
\t/home/tidb/go_projects/src/github.com/tidb/tidb/server/conn.go:2011
github.com/pingcap/tidb/server.(*clientConn).handleQuery
\t/home/tidb/go_projects/src/github.com/tidb/tidb/server/conn.go:1802
github.com/pingcap/tidb/server.(*clientConn).dispatch
\t/home/tidb/go_projects/src/github.com/tidb/tidb/server/conn.go:1289
github.com/pingcap/tidb/server.(*clientConn).Run
\t/home/tidb/go_projects/src/github.com/tidb/tidb/server/conn.go:1068
github.com/pingcap/tidb/server.(*Server).onConn
\t/home/tidb/go_projects/src/github.com/tidb/tidb/server/server.go:700

4. What is your TiDB version? (Required)

+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tidb_version() |
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Release Version: v7.4.0-alpha-406-g1159bc8d88
Edition: Community
Git Commit Hash: 1159bc8
Git Branch: master
UTC Build Time: 2023-09-14 01:10:11
GoVersion: go1.21.0
Race Enabled: false
Check Table Before Drop: false
Store: unistore |
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

Metadata

Metadata

Assignees

Labels

affects-6.5This bug affects the 6.5.x(LTS) versions.affects-7.1This bug affects the 7.1.x(LTS) versions.affects-7.5This bug affects the 7.5.x(LTS) versions.affects-8.1This bug affects the 8.1.x(LTS) versions.severity/majorsig/plannerSIG: Plannertype/bugThe issue is confirmed as a bug.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions