【 TiDB 版本】
v6.1.0
【遇到的问题】
从5.4.1升级到6.1.0,开启动态裁剪模式,执行sql ’ANALYZE TABLE table_name ALL COLUMNS; ‘,出现该报错。
【问题现象及影响】
重建表后 show stats_meta 可以看到汇总的global统计信息,但是插入数据再进行analyze的时候还是会报错。
- 默认的 static 模式报错吗?
- 麻烦上传下完整的表结构。
- 麻烦上传下完整的 tidb.log 日志中的报错信息。
static模式没有报错
表结构:
CREATE TABLE weibo_user
(
id
bigint(20) unsigned NOT NULL,
name
varchar(45) NOT NULL,
homeurl
varchar(1024) NOT NULL,
description
varchar(500) DEFAULT NULL,
profile_image_url
varchar(1024) DEFAULT NULL,
location
varchar(45) DEFAULT NULL,
province
varchar(20) DEFAULT NULL,
city
varchar(20) DEFAULT NULL,
gender
varchar(45) DEFAULT NULL,
birthday
date DEFAULT NULL,
age
varchar(45) DEFAULT NULL,
interests
text DEFAULT NULL,
followers_count
int(11) NOT NULL DEFAULT ‘0’,
friends_count
int(11) NOT NULL DEFAULT ‘0’ ,
statuses_count
int(11) NOT NULL DEFAULT ‘0’ ,
buy_power
tinyint(4) DEFAULT NULL,
life_stage
varchar(10) DEFAULT NULL,
career_label
varchar(20) DEFAULT NULL,
is_navy
tinyint(4) DEFAULT NULL,
navy_probability
float(9,8) DEFAULT NULL,
verified
tinyint(1) DEFAULT ‘0’,
verified_type
smallint(6) DEFAULT NULL,
verifiyType
tinyint(4) NOT NULL DEFAULT ‘4’,
verified_reason
varchar(100) DEFAULT NULL,
verified_detail
json DEFAULT NULL,
verified_level
tinyint(4) DEFAULT NULL,
active
tinyint(1) DEFAULT ‘0’,
created_at
datetime DEFAULT NULL,
spidertime
datetime NOT NULL,
create_time
timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
update_time
timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (id
) /*T![clustered_index] CLUSTERED */,
KEY inx_name
(name
),
KEY idx_create_time
(create_time
)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
PARTITION BY HASH (id
) PARTITIONS 128;
tidb.log:
[2022/06/28 16:36:05.847 +08:00] [INFO] [analyze.go:252] [“analyze table mbase_test
.weibo_user
has finished”] [partition=p127] [“job info”=“analyze table all columns with 256 buckets, 500 topn, 0.7949470276207958 samplerate”] [“start time”=2022/06/28 16:15:30.120 +08:00] [“end time”=2022/06/28 16:36:05.829 +08:00] [cost=20m35.708522053s]
[2022/06/28 16:37:12.601 +08:00] [ERROR] [conn.go:1056] [“connection running loop panic”] [conn=2401122288830536617] [lastSQL=“ANALYZE TABLE mbase_test.weibo_user ALL COLUMNS”] [err=“runtime error: index out of range [2048] with length 2048”] [stack=“github.com/pingcap/tidb/server.(*clientConn).Run.func1\
\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/server/conn.go:1059\
runtime.gopanic\
\t/usr/local/go/src/runtime/panic.go:838\ngithub.com/pingcap/tidb/executor.(*ExecStmt).Exec.func1\
\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/executor/adapter.go:371\
runtime.gopanic\
\t/usr/local/go/src/runtime/panic.go:838\
runtime.goPanicIndex\
\t/usr/local/go/src/runtime/panic.go:89\ngithub.com/pingcap/tidb/util/chunk.(*Column).GetFloat64\
\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/util/chunk/column.go:557\ngithub.com/pingcap/tidb/util/chunk.Row.GetFloat64\
\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/util/chunk/row.go:68\
github.com/pingcap/tidb/util/chunk.Compare\
\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/util/chunk/compare.go:195\
github.com/pingcap/tidb/util/chunk.(*Chunk).LowerBound.func1\
\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/util/chunk/compare.go:227\
sort.Search\
\t/usr/local/go/src/sort/search.go:66\ngithub.com/pingcap/tidb/util/chunk.(*Chunk).LowerBound\
\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/util/chunk/compare.go:226\ngithub.com/pingcap/tidb/statistics.(*Histogram).locateBucket\
\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/statistics/histogram.go:481\ngithub.com/pingcap/tidb/statistics.(*Histogram).equalRowCount\
\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/statistics/histogram.go:440\ngithub.com/pingcap/tidb/statistics.MergePartTopN2GlobalTopN\
\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/statistics/cmsketch.go:781\
github.com/pingcap/tidb/statistics/handle.(*Handle).mergePartitionStats2GlobalStats\
\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/statistics/handle/handle.go:514\ngithub.com/pingcap/tidb/statistics/handle.(*Handle).MergePartitionStats2GlobalStatsByTableID\
\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/statistics/handle/handle.go:405\ngithub.com/pingcap/tidb/executor.(*AnalyzeExec).Next\
\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/executor/analyze.go:210\ngithub.com/pingcap/tidb/executor.Next\
\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/executor/executor.go:319\
github.com/pingcap/tidb/executor.(*ExecStmt).handleNoDelayExecutor\
\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/executor/adapter.go:665\ngithub.com/pingcap/tidb/executor.(*ExecStmt).handleNoDelay\
\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/executor/adapter.go:516\ngithub.com/pingcap/tidb/executor.(*ExecStmt).Exec\
\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/executor/adapter.go:465\ngithub.com/pingcap/tidb/session.runStmt\
\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/session/session.go:2069\
github.com/pingcap/tidb/session.(*session).ExecuteStmt\
\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/session/session.go:1938\ngithub.com/pingcap/tidb/server.(*TiDBContext).ExecuteStmt\
\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/server/driver_tidb.go:230\ngithub.com/pingcap/tidb/server.(*clientConn).handleStmt\
\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/server/conn.go:2022\ngithub.com/pingcap/tidb/server.(*clientConn).handleQuery\
\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/server/conn.go:1876\ngithub.com/pingcap/tidb/server.(*clientConn).dispatch\
\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/server/conn.go:1371\ngithub.com/pingcap/tidb/server.(*clientConn).Run\
\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/server/conn.go:1121\ngithub.com/pingcap/tidb/server.(*Server).onConn\
\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/server/server.go:559”]
[2022/06/28 16:38:51.055 +08:00] [INFO] [domain.go:1749] [“refreshServerIDTTL succeed”] [serverID=1091904] [“lease id”=6eca81715eb7a38f]
- 我测试没有复现。在 v5.4.0 创建表,升级到 v6.1.0 ,再修改为动态裁剪模式,再收集信息。
- 能否麻烦您收集下这张表的统计信息,根据您的统计信息我再试试。
https://docs.pingcap.com/zh/tidb/stable/statistics#统计信息的导入导出
- 感谢,尝试导入统计信息,再升级,set dynamic,然后 analyze 之后,还是成功了。
- 看了下您的统计信息,每个分区差不多快 7 万的数据。 127 个分区共 890 万 的数据。
- 和这个问题应该类似 https://github.com/pingcap/tidb/issues/34228 ,可能需要数据来复现问题。辛苦帮忙导出下这个表的数据是否可以?如果能给几行数据,可以复现问题的最好。
- 另外,我们从代码方面也再持续分析。
升级前 5.4.1 版本有遇到问题吗
重新试了一遍,新建表,分别用7千、1.2万、5万、8.8万、15万数据测试,数据量较少的都没有报错,8.8万和15万数据的 analyze 都报错了。
在 5.4.1 版本测试了一下,static 正常,dynamic 报错相同
这8.8 万数据您能修改下,达到不会影响你们正常业务数据安全性。之后导出发送,我们来复现下问题吗?多谢。
抱歉,问了领导,修改了也不能提供,您看您可以造一些数据么
哈喽,我这边确认了问题,是 float 类型引起的,您可以试一下,数据我这边准备了,可复现
CREATE TABLE t1
(
id
bigint(20) unsigned NOT NULL AUTO_INCREMENT,
num
float(9,8) DEFAULT NULL,
PRIMARY KEY (id
) /*T![clustered_index] CLUSTERED */
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
PARTITION BY HASH (id
) PARTITIONS 128;
t1_202207011138.sql (33.2 KB)
每一次出现这个问题,连接都会断开