Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.
Original topic: tidb_server_connections存在小于0的值
After upgrading to 7.5.2, I found that in some scenarios, the total number of connections for tidb-server in the monitoring is actually a negative number.
Strange, could it be a bug or a misunderstanding?
Before version 7.5.2, there was indeed this bug. But judging by the fix time, it should be resolved in 7.5.2.
Maybe these erroneous data were from before the upgrade?
Not sure if that’s the case. If it’s still wrong, please provide feedback in the issue to check.
Uh, I also reported this BUG. Previously, it was even more exaggerated, almost all zeros. Also, looking at it today, the value has become -65, and it will probably keep accumulating…
The connection is 0 and cannot be negative.
You forgot to categorize it under product defects!
Uh, indeed, it was only put in the suggestions and feedback section…
It’s a bug that has always existed, but it’s not a big deal.
This is a known issue, and you can track the progress with this issue: The Connection Count panel in the Grafana dashboard is inaccurate. · Issue #54428 · pingcap/tidb · GitHub. This problem is relatively difficult to pinpoint as it involves a lot of code. If you have any scenarios or clues that trigger the issue, please provide them. Thank you.
Now it’s even more exaggerated. The total number of connections for the tidb-server node ending in 245, which is set to default, has actually reached -1724.
If the connection exits before it is fully established, it may cause the Connection Count to decrease by one, making it smaller than the actual value. An easy way to reproduce this is: use the MySQL CLI to connect to a non-existent user (or connect with an incorrect password), and TiDB’s Connection Count will decrease by one, making it smaller than the actual value.
There is a PR fixing this issue! server: refine the connection counter logic by YangKeao · Pull Request #54546 · pingcap/tidb · GitHub
Looking forward to the official solution.