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

panic during partition location for key and hash partition #54667

Closed
wjhuang2016 opened this issue Jul 16, 2024 · 2 comments · Fixed by #54686
Closed

panic during partition location for key and hash partition #54667

wjhuang2016 opened this issue Jul 16, 2024 · 2 comments · Fixed by #54686
Assignees
Labels
affects-8.1 This bug affects the 8.1.x(LTS) versions. component/tablepartition This issue is related to Table Partition of TiDB. fuzz/randomtest impact/panic severity/moderate sig/sql-infra SIG: SQL Infra type/bug The issue is confirmed as a bug.

Comments

@wjhuang2016
Copy link
Member

wjhuang2016 commented Jul 16, 2024

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

update tad8c9f80 set tad8c9f80.col_44 = 'AH6' ,tad8c9f80.col_43 = 'O%uH' ,tad8c9f80.col_38 = 7194.863539582079 where tad8c9f80.col_42 in ( 7691699 ,11807884 ,10523838 ,15662349 ,6970066 )  
github.com/pingcap/tidb/pkg/server.(*clientConn).Run.func1
	/Users/pingcap/workspace/bp-tidb-release-darwin-arm64-hpbc2-build-binaries/source/tidb/pkg/server/conn.go:1040
runtime.gopanic
	/usr/local/go1.21/src/runtime/panic.go:914
github.com/pingcap/tidb/pkg/executor.(*ExecStmt).Exec.func1
	/Users/pingcap/workspace/bp-tidb-release-darwin-arm64-hpbc2-build-binaries/source/tidb/pkg/executor/adapter.go:481
runtime.gopanic
	/usr/local/go1.21/src/runtime/panic.go:914
runtime.goPanicIndex
	/usr/local/go1.21/src/runtime/panic.go:114
github.com/pingcap/tidb/pkg/table/tables.(*ForKeyPruning).LocateKeyPartition
	/Users/pingcap/workspace/bp-tidb-release-darwin-arm64-hpbc2-build-binaries/source/tidb/pkg/table/tables/partition.go:321
github.com/pingcap/tidb/pkg/table/tables.(*partitionedTable).locatePartitionCommon
	/Users/pingcap/workspace/bp-tidb-release-darwin-arm64-hpbc2-build-binaries/source/tidb/pkg/table/tables/partition.go:1318
github.com/pingcap/tidb/pkg/table/tables.(*partitionedTable).locatePartitionIdx
	/Users/pingcap/workspace/bp-tidb-release-darwin-arm64-hpbc2-build-binaries/source/tidb/pkg/table/tables/partition.go:1333
github.com/pingcap/tidb/pkg/table/tables.(*partitionedTable).GetPartitionIdxByRow
	/Users/pingcap/workspace/bp-tidb-release-darwin-arm64-hpbc2-build-binaries/source/tidb/pkg/table/tables/partition.go:1549
github.com/pingcap/tidb/pkg/planner/core.(*BatchPointGetPlan).PrunePartitionsAndValues
	/Users/pingcap/workspace/bp-tidb-release-darwin-arm64-hpbc2-build-binaries/source/tidb/pkg/planner/core/point_get_plan.go:762
github.com/pingcap/tidb/pkg/executor.(*executorBuilder).buildBatchPointGet
	/Users/pingcap/workspace/bp-tidb-release-darwin-arm64-hpbc2-build-binaries/source/tidb/pkg/executor/builder.go:5161
github.com/pingcap/tidb/pkg/executor.(*executorBuilder).build
	/Users/pingcap/workspace/bp-tidb-release-darwin-arm64-hpbc2-build-binaries/source/tidb/pkg/executor/builder.go:198
github.com/pingcap/tidb/pkg/executor.(*executorBuilder).buildUnionAll
	/Users/pingcap/workspace/bp-tidb-release-darwin-arm64-hpbc2-build-binaries/source/tidb/pkg/executor/builder.go:2490
github.com/pingcap/tidb/pkg/executor.(*executorBuilder).build
	/Users/pingcap/workspace/bp-tidb-release-darwin-arm64-hpbc2-build-binaries/source/tidb/pkg/executor/builder.go:254
github.com/pingcap/tidb/pkg/executor.(*executorBuilder).buildUpdate
	/Users/pingcap/workspace/bp-tidb-release-darwin-arm64-hpbc2-build-binaries/source/tidb/pkg/executor/builder.go:2586
github.com/pingcap/tidb/pkg/executor.(*executorBuilder).build
	/Users/pingcap/workspace/bp-tidb-release-darwin-arm64-hpbc2-build-binaries/source/tidb/pkg/executor/builder.go:256
github.com/pingcap/tidb/pkg/executor.(*ExecStmt).buildExecutor
	/Users/pingcap/workspace/bp-tidb-release-darwin-arm64-hpbc2-build-binaries/source/tidb/pkg/executor/adapter.go:1203
github.com/pingcap/tidb/pkg/executor.(*ExecStmt).Exec
	/Users/pingcap/workspace/bp-tidb-release-darwin-arm64-hpbc2-build-binaries/source/tidb/pkg/executor/adapter.go:552
github.com/pingcap/tidb/pkg/session.runStmt
	/Users/pingcap/workspace/bp-tidb-release-darwin-arm64-hpbc2-build-binaries/source/tidb/pkg/session/session.go:2289
github.com/pingcap/tidb/pkg/session.(*session).ExecuteStmt
	/Users/pingcap/workspace/bp-tidb-release-darwin-arm64-hpbc2-build-binaries/source/tidb/pkg/session/session.go:2150
github.com/pingcap/tidb/pkg/server.(*TiDBContext).ExecuteStmt
	/Users/pingcap/workspace/bp-tidb-release-darwin-arm64-hpbc2-build-binaries/source/tidb/pkg/server/driver_tidb.go:291
github.com/pingcap/tidb/pkg/server.(*clientConn).handleStmt
	/Users/pingcap/workspace/bp-tidb-release-darwin-arm64-hpbc2-build-binaries/source/tidb/pkg/server/conn.go:2044
github.com/pingcap/tidb/pkg/server.(*clientConn).handleQuery
	/Users/pingcap/workspace/bp-tidb-release-darwin-arm64-hpbc2-build-binaries/source/tidb/pkg/server/conn.go:1798
github.com/pingcap/tidb/pkg/server.(*clientConn).dispatch
	/Users/pingcap/workspace/bp-tidb-release-darwin-arm64-hpbc2-build-binaries/source/tidb/pkg/server/conn.go:1372
github.com/pingcap/tidb/pkg/server.(*clientConn).Run
	/Users/pingcap/workspace/bp-tidb-release-darwin-arm64-hpbc2-build-binaries/source/tidb/pkg/server/conn.go:1138
github.com/pingcap/tidb/pkg/server.(*Server).onConn
	/Users/pingcap/workspace/bp-tidb-release-darwin-arm65-hpbc2-build-binaries/source/tidb/pkg/server/server.go:739
mysql> show create table tad8c9f80;
+-----------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table     | Create Table                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
+-----------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tad8c9f80 | CREATE TABLE `tad8c9f80` (
  `col_37` text COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `col_38` float NOT NULL DEFAULT '3514.3777',
  `col_39` datetime DEFAULT NULL,
  `col_40` bit(12) NOT NULL,
  `col_41` float NOT NULL,
  `col_42` mediumint(8) unsigned NOT NULL DEFAULT '11075363',
  `col_43` binary(171) DEFAULT 'v@O+MkoF6(zDD\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0',
  `col_44` tinyblob NOT NULL,
  `col_45` varchar(174) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT 'ax&7',
  PRIMARY KEY (`col_42`) /*T![clustered_index] CLUSTERED */
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
PARTITION BY KEY (`col_42`) PARTITIONS 7 |
+-----------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

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

No panic

3. What did you see instead (Required)

Panic

4. What is your TiDB version? (Required)

master

@wjhuang2016 wjhuang2016 added type/bug The issue is confirmed as a bug. fuzz/randomtest labels Jul 16, 2024
@Defined2014
Copy link
Contributor

Defined2014 commented Jul 16, 2024

Reproduction SQLs:

set tidb_partition_prune_mode=static;
CREATE TABLE `tad8c9f80` (
  `col_37` text COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `col_38` float NOT NULL DEFAULT '3514.3777',
  `col_39` datetime DEFAULT NULL,
  `col_40` bit(12) NOT NULL,
  `col_41` float NOT NULL,
  `col_42` mediumint(8) unsigned NOT NULL DEFAULT '11075363',
  `col_43` binary(171) DEFAULT 'v@O+MkoF6(zDD\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0',
  `col_44` tinyblob NOT NULL,
  `col_45` varchar(174) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT 'ax&7',
  PRIMARY KEY (`col_42`) /*T![clustered_index] CLUSTERED */
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
PARTITION BY KEY (`col_42`) PARTITIONS 7;
insert into tad8c9f80 values ('a',4.3,20240702,1,1.23,6970066,'0a','a','c');
explain update tad8c9f80 set tad8c9f80.col_44 = 'AH6' ,tad8c9f80.col_43 = 'O%uH' ,tad8c9f80.col_38 = 7194.863539582079 where tad8c9f80.col_42 in ( 7691699 ,11807884 ,10523838 ,15662349 ,6970066 );

@Defined2014 Defined2014 added sig/sql-infra SIG: SQL Infra component/tablepartition This issue is related to Table Partition of TiDB. severity/moderate labels Jul 16, 2024
@Defined2014 Defined2014 changed the title panic during partition location for key partition panic during partition location for key and hash partition Jul 17, 2024
@Defined2014
Copy link
Contributor

Defined2014 commented Jul 17, 2024

The problem is caused by #49161, the case is static prune + batchPointGet. /cc @mjonss

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-8.1 This bug affects the 8.1.x(LTS) versions. component/tablepartition This issue is related to Table Partition of TiDB. fuzz/randomtest impact/panic severity/moderate sig/sql-infra SIG: SQL Infra type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants