【TiDB 使用环境】生产环境
【TiDB 版本】8.5.2
【部署方式】本地24个TIKV节点
【遇到的问题:问题现象及影响】
tidb_server 节点错误日志:[2025/06/10 15:49:14.062 +08:00] [ERROR] [distsql.go:1567] [“table reader fetch next chunk failed”] [conn=516137088] [session_alias=] [error=“context canceled”]
[2025/06/10 15:49:19.371 +08:00] [ERROR] [distsql.go:1567] [“table reader fetch next chunk failed”] [conn=516137546] [session_alias=] [error=“context canceled”]
[2025/06/10 15:49:19.371 +08:00] [ERROR] [distsql.go:1567] [“table reader fetch next chunk failed”] [conn=516137546] [session_alias=] [error=“context canceled”]
[2025/06/10 15:49:19.540 +08:00] [ERROR] [distsql.go:1567] [“table reader fetch next chunk failed”] [conn=516137456] [session_alias=] [error=“context canceled”]
[2025/06/10 15:49:25.249 +08:00] [ERROR] [distsql.go:1567] [“table reader fetch next chunk failed”] [conn=516137076] [session_alias=] [error=“context canceled”]
[2025/06/10 15:49:32.167 +08:00] [ERROR] [distsql.go:1567] [“table reader fetch next chunk failed”] [conn=516137270] [session_alias=] [error=“context canceled”]
[2025/06/10 15:49:33.082 +08:00] [ERROR] [distsql.go:1567] [“table reader fetch next chunk failed”] [conn=516137436] [session_alias=] [error=“context canceled”]
[2025/06/10 15:49:33.082 +08:00] [ERROR] [distsql.go:1567] [“table reader fetch next chunk failed”] [conn=516137436] [session_alias=] [error=“context canceled”]
[2025/06/10 15:50:38.617 +08:00] [ERROR] [distsql.go:1567] [“table reader fetch next chunk failed”] [conn=516137554] [session_alias=] [error=“context canceled”]
[2025/06/10 15:54:43.124 +08:00] [ERROR] [distsql.go:1567] [“table reader fetch next chunk failed”] [conn=516137210] [session_alias=] [error=“context canceled”]
[2025/06/10 15:54:43.124 +08:00] [ERROR] [distsql.go:1567] [“table reader fetch next chunk failed”] [conn=516137210] [session_alias=] [error=“context canceled”]
[2025/06/10 15:54:43.124 +08:00] [ERROR] [distsql.go:1567] [“table reader fetch next chunk failed”] [conn=516137210] [session_alias=] [error=“context canceled”]
[2025/06/10 15:54:43.290 +08:00] [ERROR] [distsql.go:1567] [“table reader fetch next chunk failed”] [conn=516137032] [session_alias=] [error=“context canceled”]
[2025/06/10 15:59:46.824 +08:00] [ERROR] [distsql.go:1567] [“table reader fetch next chunk failed”] [conn=516137414] [session_alias=] [error=“context canceled”]
[2025/06/10 15:59:46.824 +08:00] [ERROR] [distsql.go:1567] [“table reader fetch next chunk failed”] [conn=516137414] [session_alias=] [error=“context canceled”]
[2025/06/10 15:59:47.069 +08:00] [ERROR] [distsql.go:1567] [“table reader fetch next chunk failed”] [conn=516137266] [session_alias=] [error=“context canceled”]
[2025/06/10 15:59:47.069 +08:00] [ERROR] [distsql.go:1567] [“table reader fetch next chunk failed”] [conn=516137266] [session_alias=] [error=“context canceled”
现象:程序端查询能正常出结果,只是每次查询tidb_server 节点都会出现一次错误
原因是:表的一个索引引起的,把问题索引删除重建后,现象消失
表结构:-- crawler_platform.journal_article definition
CREATE TABLE journal_article
(
id
bigint NOT NULL AUTO_INCREMENT,
task_name
varchar(100) DEFAULT NULL,
task_tag
varchar(50) DEFAULT NULL,
rawid
varchar(500) NOT NULL DEFAULT ‘’,
article_info_json
json DEFAULT NULL,
sub_db_id
varchar(10) NOT NULL,
state
int NOT NULL DEFAULT ‘0’ COMMENT ‘-1 状态为删除的数据’,
failcount
int NOT NULL DEFAULT ‘0’,
ref_stat
int NOT NULL DEFAULT ‘0’,
ref_failcount
int NOT NULL DEFAULT ‘0’,
cite_stat
int NOT NULL DEFAULT ‘0’,
cite_failcount
int NOT NULL DEFAULT ‘0’,
oversea
int NOT NULL DEFAULT ‘0’,
oversea_failcount
int NOT NULL DEFAULT ‘0’,
t1
int NOT NULL DEFAULT ‘0’,
t1_failcount
int NOT NULL DEFAULT ‘0’,
re_down
int NOT NULL DEFAULT ‘1’ COMMENT ‘1为第一次下载,2为10天后的下载,3为30天后的下载,4为90天后的下载’,
is_true
int NOT NULL DEFAULT ‘0’,
is_true_failcount
int NOT NULL DEFAULT ‘0’,
create_time
timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
update_time
timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
err_msg
text DEFAULT NULL,
other_dicts
text DEFAULT NULL,
null_dicts
text DEFAULT NULL,
page
varchar(255) NOT NULL DEFAULT ‘0’ COMMENT ‘占位,不会用于实际请求中’,
PRIMARY KEY (id
) /*T![clustered_index] NONCLUSTERED */,
UNIQUE KEY m_rawid
(task_name
,task_tag
,rawid
),
KEY is_true_dx
(is_true
,is_true_failcount
),
KEY state_dx
(state
,failcount
),
KEY update_dx
(update_time
),
KEY tag_isture_dx
(task_name
,task_tag
,is_true
,is_true_failcount
),
KEY idx_tname_ttag_istrue_ctime
(task_name
,task_tag
,is_true
,is_true_failcount
,create_time
),
KEY journal_article_create_time_IDX
(create_time
)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin AUTO_INCREMENT=8404287708;
表数据总计大小100GB
问题索引:journal_article_create_time_IDX
执行SQL:SELECT * FROM journal_article
where task_name = ‘cnkijournal’ and task_tag=‘cnkiarticle’ and is_true_failcount<5 and is_true in (0,-1) ORDER BY create_time desc limit 100
其它问题 :问题出现前执行 这个SQL,索引不走idx_tname_ttag_istrue_ctime ,而是走journal_article_create_time_IDX