Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

server: TiDB cannot read the client's remote address in PROXY protocol header #41409

Closed
blacktear23 opened this issue Feb 14, 2023 · 2 comments · Fixed by #41393
Closed

server: TiDB cannot read the client's remote address in PROXY protocol header #41409

blacktear23 opened this issue Feb 14, 2023 · 2 comments · Fixed by #41393
Labels

Comments

@blacktear23
Copy link
Contributor

blacktear23 commented Feb 14, 2023

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

  1. start TiDB server with PROXY protocol enabled
  2. configure a haproxy and enable PROXY protocol to backend
  3. use mysql command connect to TiDB server
  4. use show processlist; check the client IP and port

It will show the IP and port from Haproxy server.

2. What did you expect to see? (Required)

show processlist; should show client IP and port that connected to Haproxy.

3. What did you see instead (Required)

show processlist; shows Haproxy server's IP and port.

4. What is your TiDB version? (Required)

from TiDB 6.3.0 to master

5. Reason

From TiDB 6.3.0 it introduce the PROXY protocol lazy mode that can let proxyprotocol library can parse the PROXY protocol header when first Read function call. But at server/conn.go function PeerHost it will cache the connection remote address at first call. And server/server.go function startNetworkListener it will call PeerHost before do the mysql protocol handshake. At that time, the conn.Read not called anymore, so the remote address is connection's remote address not the remote address in PROXY protocol header.

@blacktear23 blacktear23 added the type/bug The issue is confirmed as a bug. label Feb 14, 2023
@bb7133 bb7133 added affects-5.3 This bug affects 5.3.x versions. affects-5.4 This bug affects 5.4.x versions. affects-6.1 affects-6.5 labels Feb 14, 2023
@blacktear23
Copy link
Contributor Author

@bb7133 from 6.3

1 similar comment
@blacktear23
Copy link
Contributor Author

@bb7133 from 6.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants