表查询报错 PD server timeout

【TiDB 使用环境】生产环境 /测试环境
【TiDB 版本】7.5.0
【部署方式】虚拟机部署

业务查询某张表报错:PD server timeout

检查日志发现都是 autoanalyze 报错:
[autoanalyze.go:435] [“auto analyze failed”] [category=stats] [sql=“analyze table xxxxx.xxxxx partition xxxxx”] [cost_time=11.243548842s] [error="[tikv:9001]PD server timeout: "]

集群状态都是正常的,只有某几张表无法查询。

1 个赞

pd负载高?是不是可以看看pd的日志?

1 个赞

1 个赞

Region 数量有点多

1 个赞

有什么解决方案吗?

1 个赞

看截图好像没什么太大的异常,不能查询的表是analyze的表么? 将统计信息的任务暂时停掉,能否正常执行的。

1 个赞

PD 的日志里面有没有什么错误

1 个赞

是的,这个任务在哪里可以停掉

2 个赞

资源争用严重了吧

1 个赞

只有某几张表无法查询

检查这几张表吧,最好手动 analyze 一下

1 个赞

analyze 表也报一样的错

1 个赞

数据可以查询么?

可以的话,最好新建一张表,把数据挪过去,试试看

1 个赞

临时停 autoanalyze(set global tidb_auto_analyze_enable=0),手动调优 PD 参数,长期建议清理冗余 Region 或升级版本。

1 个赞

[2026/01/21 09:07:17.782 +07:00] [ERROR] [apiutil.go:419] [“request failed”] [error=“[PD:http:ErrSendRequest]Get "http://10.235.38.64:2379/pd/api/v1/ping\”: context canceled: Get "http://10.235.38.64:2379/pd/api/v1/ping\“: context canceled”]
[2026/01/21 09:07:29.443 +07:00] [ERROR] [grpclog.go:75] [“transport: loopyWriter.run returning. Err: write tcp 10.235.38.66:2379->10.235.38.64:59866: write: broken pipe”]
[2026/01/21 09:07:29.334 +07:00] [ERROR] [etcdutil.go:422] [“failed to list members”] [error=“context deadline exceeded”]
[2026/01/21 09:36:56.958 +07:00] [ERROR] [client.go:150] [“region sync with leader meet error”] [error=“[PD:grpc:ErrGRPCRecv]rpc error: code = Canceled desc = context canceled: rpc error: code = Canceled desc = context canceled”]
[2026/01/21 13:26:52.073 +07:00] [ERROR] [etcdutil.go:152] [“load from etcd meet error”] [key=/pd/7355341457185982298/member/8314904980276262071/leader_priority] [error=“[PD:etcd:ErrEtcdKVGet]context deadline exceeded: context deadline exceeded”]
[2026/01/21 13:26:52.073 +07:00] [ERROR] [member.go:274] [“failed to load leader priority”] [error=“[PD:etcd:ErrEtcdKVGet]context deadline exceeded: context deadline exceeded”]
[2026/01/21 13:26:54.567 +07:00] [ERROR] [etcdutil.go:152] [“load from etcd meet error”] [key=/pd/7355341457185982298/config] [error=“[PD:etcd:ErrEtcdKVGet]context deadline exceeded: context deadline exceeded”]
[2026/01/21 13:26:55.393 +07:00] [ERROR] [client.go:150] [“region sync with leader meet error”] [error=“[PD:grpc:ErrGRPCRecv]rpc error: code = Canceled desc = context canceled: rpc error: code = Canceled desc = context canceled”]
[2026/01/21 13:28:17.251 +07:00] [ERROR] [etcdutil.go:422] [“failed to list members”] [error=“context deadline exceeded”]
[2026/01/21 13:28:17.305 +07:00] [ERROR] [apiutil.go:419] [“request failed”] [error=“[PD:http:ErrSendRequest]Get "http://10.235.38.64:2379/pd/api/v1/ping\”: context canceled: Get "http://10.235.38.64:2379/pd/api/v1/ping\“: context canceled”]
[2026/01/21 13:28:17.315 +07:00] [ERROR] [etcdutil.go:422] [“failed to list members”] [error=“context deadline exceeded”]
[2026/01/21 13:28:17.317 +07:00] [ERROR] [etcdutil.go:152] [“load from etcd meet error”] [key=/pd/7355341457185982298/member/8314904980276262071/leader_priority] [error=“[PD:etcd:ErrEtcdKVGet]context deadline exceeded: context deadline exceeded”]
[2026/01/21 13:28:17.318 +07:00] [ERROR] [member.go:274] [“failed to load leader priority”] [error=“[PD:etcd:ErrEtcdKVGet]context deadline exceeded: context deadline exceeded”]
[2026/01/21 13:28:17.592 +07:00] [ERROR] [client.go:150] [“region sync with leader meet error”] [error=“[PD:grpc:ErrGRPCRecv]rpc error: code = Canceled desc = context canceled: rpc error: code = Canceled desc = context canceled”]

表数据量是不是太大或者分区数是不是很多?执行如下命令试试是否报错:ANALYZE TABLE your_table PARTITION p1;
此外,可以重启下有问题的pd节点(10.235.38.64)试试

对,手动analyze是否报错? 实在不行改下tikv-client:
pd-server-timeout: 30s # 默认可能是 10s 或 15s,适当调大

pd日志是否有频繁选主?

  • 目标表(分区)数据量过大 / 分区过多:autoanalyze 分区表时,若单个分区数据量巨大(如数十亿行)或分区数量过多,分析操作会消耗大量 TiDB 节点 CPU / 内存,同时频繁与 PD 交互获取 Region 信息,超过 PD 的交互超时阈值(默认有内部超时限制),导致超时失败。
  • PD 与 TiDB/TiKV 节点网络延迟 / 抖动:虚拟机部署环境可能存在虚拟网络带宽不足、网卡瓶颈或节点间网络抖动,autoanalyze 和查询操作对 PD 的高频请求在网络不佳时,容易触发超时(尤其是大表操作,交互次数更多)。
  • 统计信息相关配置不合理:TiDB 的 autoanalyze 触发阈值、超时配置与当前集群资源不匹配,大表分析时无法在合理时间内完成,最终导致 PD 超时;同时,表的统计信息失效后,查询优化器生成的执行计划可能引发大量无效 PD 请求,加剧超时。
  • 影响:autoanalyze 失败会导致表的统计信息陈旧 / 缺失,查询时 TiDB 优化器无法生成最优执行计划,可能引发全表扫描、大量 Region 遍历,进一步增加与 PD 的交互压力,最终查询也报 PD timeout。

手动 analyze 也是报错的

analyze 也是报错的,重启pd节点也无法解决

1 个赞