-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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: compatible to old handshake protocol #8812
Conversation
7c09c6c
to
eae108c
Compare
/run-all-tests |
/run-unit-test |
3ffb782
to
43db3f5
Compare
/run-all-tests |
server/conn.go
Outdated
var resp handshakeResponse41 | ||
|
||
pos, err := parseHandshakeResponseHeader(&resp, data) | ||
if err != nil { | ||
return errors.Trace(err) | ||
if err == mysql.ErrMalformPacket { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Protocol::HandshakeResponse41:
Handshake Response Packet sent by 4.1+ clients supporting CLIENT_PROTOCOL_41 capability, if the server announced it in its Initial Handshake Packet. Otherwise (talking to an old server) the Protocol::HandshakeResponse320 packet must be used.
https://dev.mysql.com/doc/internals/en/connection-phase-packets.html
@imtbkcat can we direct use CLIENT_PROTOCOL_41 capability
to decide use 41 or 32, because our Initial Handshake Packet always contain ClientProtocol41
?
parse handshake twice has risk
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
server/conn.go
Outdated
// parseHandshakeResponseHeader parses the common header of SSLRequest and HandshakeResponse41. | ||
func parseHandshakeResponseHeader(packet *handshakeResponse41, data []byte) (parsedBytes int, err error) { | ||
// Ensure there are enough data to read: | ||
// http://dev.mysql.com/doc/internals/en/connection-phase-packets.html#packet-Protocol::SSLRequest | ||
if len(data) < 4+4+1+23 { | ||
log.Errorf("Got malformed handshake response, packet data: %v", data) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's better to add it back if we don't parse protocol 41 first.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jackysp addressed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
/run-all-tests |
What problem does this PR solve?
When using HAProxy connect to TiDB server,
option mysql-check user root
will cause handshake fail error because TiDB do not support Protocol::HandshakeResponse320What is changed and how it works?
Parser
Protocol::HandshakeResponse320
toProtocol::HandshakeResponse41
, which is supported by TiDB.Check List
Tests
Code changes
Side effects
Related changes
This change is