The startup time of tidb-server in TiDB 6.5 has increased, with the main time consumption occurring during the "init stats" phase

Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.

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

| username: dba-kit

As shown in the logs below, the init stats itself takes up more than 90% of the time, causing the tidb-server to take a long time to return to normal after a restart.
PS: Sometimes there is also a loading failure with the error init stats info failed. When logging in to query, everything seems normal. This should be during the loading of statistical information. Is it possible to move this to the background after the server successfully starts on port 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]
| username: dba-kit | Original post link

I found it. In version 6.1.2, it indeed serves port 4000 first and then asynchronously loads the stats information.

| username: 我是咖啡哥 | Original post link

Does this error affect usage?

| username: dba-kit | Original post link

It is still unclear what the final impact of the init stats action will be. Currently, it seems that queries are not affected.

| username: mayjiang0203 | Original post link

We will first use this issue server is slow to start and cannot provide services · Issue #40548 · pingcap/tidb · GitHub to track this problem. Please follow the progress of this issue. Thank you for your feedback.

| username: system | Original post link

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.