TiDB 6.5的tidb-server启动时间变长,主要耗时在"init stats"阶段

如下日志所展示,init stats自己占用了90%以上的时间,导致tidb-server现在发生重启后,很长时间才能恢复正常。
PS:有时候还会出现加载失败,出现init stats info failed的报错,登陆查询,看起来也都正常。这个应该是加载统计信息阶段,是否可以在serve 4000端口成功后,放到后台来搞?

[2023/01/11 16:54:00.581 +08:00] [INFO] [printer.go:34] ["Welcome to TiDB."] ["Release Version"=v6.5.0] [Edition=Community] ["Git Commit Hash"=706c3fa3c526cdba5b3e9f066b1a568fb96c56e3] ["Git Branch"=heads/refs/tags/v6.5.0] ["UTC Build Time"="2022-12-27 03:50:44"] [GoVersion=go1.19.3] ["Race Enabled"=false] ["Check Table Before Drop"=false] ["TiKV Min Version"=6.2.0-alpha]
[2023/01/11 16:59:11.963 +08:00] [INFO] [domain.go:1882] ["init stats info time"] ["take time"=5m10.191840021s]
[2023/01/11 16:59:12.003 +08:00] [INFO] [server.go:262] ["server is running MySQL protocol"] [addr=0.0.0.0:4000]
[2023/01/11 16:59:12.005 +08:00] [INFO] [server.go:276] ["server is running MySQL protocol"] [socket=/tmp/tidb-4000.sock]
[2023/01/11 17:30:11.245 +08:00] [INFO] [printer.go:34] ["Welcome to TiDB."] ["Release Version"=v6.5.0] [Edition=Community] ["Git Commit Hash"=706c3fa3c526cdba5b3e9f066b1a568fb96c56e3] ["Git Branch"=heads/refs/tags/v6.5.0] ["UTC Build Time"="2022-12-27 03:50:44"] [GoVersion=go1.19.3] ["Race Enabled"=false] ["Check Table Before Drop"=false] ["TiKV Min Version"=6.2.0-alpha]
[2023/01/11 17:33:55.743 +08:00] [ERROR] [domain.go:1880] ["init stats info failed"] ["take time"=3m43.33511125s] [error="interface conversion: interface {} is nil, not *memory.bytesLimits"]
[2023/01/11 17:33:55.773 +08:00] [INFO] [server.go:262] ["server is running MySQL protocol"] [addr=0.0.0.0:4000]
[2023/01/11 17:33:55.773 +08:00] [INFO] [server.go:276] ["server is running MySQL protocol"] [socket=/tmp/tidb-4000.sock]

找到了,6.1.2时候确实先serve 4000端口,然后再异步加载stats信息的

这个报错不影响使用吗?

还不清楚init stats这个动作最终会影响什么,目前来看查询不受影响

这个问题我们先用 https://github.com/pingcap/tidb/issues/40548 这个 issue 跟踪,请关注这个 issue 的进展,感谢反馈。