Help: How to Accurately Locate the Source of a Query in TiDB v4.0.9?

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

Original topic: 求助:tidb v4.0.9 怎么精确定位query的来源?

| username: jaybing926

[TiDB Usage Environment] Production Environment
[TiDB Version] v4.0.9
[Encountered Problem: Phenomenon and Impact]
When using tidb show processlist, it does not display the source HOST:port information like MySQL does. Currently, there is a very slow SQL query, and I want to accurately locate its source. How can I do that? A group member mentioned that the new version will display this information, but I can’t upgrade the cluster at the moment. Can anyone suggest a way to locate the specific IP+port information? Thanks~~
[Resource Configuration]
[Attachments: Screenshots/Logs/Monitoring]

| username: 裤衩儿飞上天 | Original post link

Did you use HAProxy?
You can enable IP transparency HAProxy Best Practices in TiDB | PingCAP Docs

| username: jaybing926 | Original post link

Does it mean that it’s not a version issue, but using HAProxy that causes the port information not to be displayed?

| username: jaybing926 | Original post link

I looked at the documentation, are the following configuration steps needed:

  1. HAProxy configuration
    server tidb-1 10.9.18.229:4000 send-proxy check inter 2000 rise 2 fall 3
    server tidb-2 10.9.39.208:4000 send-proxy check inter 2000 rise 2 fall 3
    server tidb-3 10.9.64.166:4000 send-proxy check inter 2000 rise 2 fall 3
  2. TiDB configuration modification:
    proxy-protocol.networks: 192.168.241.54,192.168.241.55 #This configuration is for my HAProxy addresses

Is there any problem with my above configuration?

| username: 裤衩儿飞上天 | Original post link

Yes, that’s the configuration. However, it’s best to have your HAProxy on a separate machine. Mixing it with other components might lead to accessibility issues.

| username: jaybing926 | Original post link

It is a standalone node, but I have 2 nodes for Haproxy, which are master and slave to each other using keepalived.

| username: 裤衩儿飞上天 | Original post link

That’s okay.

| username: jaybing926 | Original post link

Okay, thank you~

| username: jaybing926 | Original post link

I followed the method mentioned above and can now display the actual IP, but the port information is still not showing. How can I get the port to display? Is this a version issue? Any solutions?

| username: 裤衩儿飞上天 | Original post link

In version 4.0, there is no port information; it only starts to appear in version 5.0.
However, having the IP is already enough to determine the source.

| username: jaybing926 | Original post link

Okay.

| username: system | Original post link

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