-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Mark connections as bad on MariaDB shutdown #451
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
Changes from all commits
74c0b49
4d31bd2
2b2d33c
78a3d69
80b57cc
7c6122e
ac5e404
53a7eb2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,8 +49,15 @@ func (mc *mysqlConn) readPacket() ([]byte, error) { | |
if data[3] > mc.sequence { | ||
return nil, ErrPktSyncMul | ||
} | ||
return nil, ErrPktSync | ||
|
||
//When MariaDB server is shutdown connection killed packet is sent | ||
//with a zero sequence number. | ||
//Continue to process it so the specific error can be detected. | ||
if data[3] != 0 { | ||
return nil, ErrPktSync | ||
} | ||
} | ||
|
||
mc.sequence++ | ||
|
||
// Read packet body [pktLen bytes] | ||
|
@@ -525,6 +532,13 @@ func (mc *mysqlConn) handleErrorPacket(data []byte) error { | |
pos = 9 | ||
} | ||
|
||
//If error code is for Connection was killed, then return bad connection. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also add a space here and put "Connection was killed" in quotes. Maybe also replace "then return bad connection" with "then mark connection as bad" |
||
//https://mariadb.com/kb/en/mariadb/mariadb-error-codes/ | ||
if errno == 1927 { | ||
errLog.Print("Error ", errno, ": ", string(data[pos:])) | ||
return driver.ErrBadConn | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's not safe, because we can't know this error was sent before sending query or not. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. my question is assuming this came after a query is sent. is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, I can't get what is your question. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So what is the difference between returning There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can close this connection ( |
||
} | ||
|
||
// Error Message [string] | ||
return &MySQLError{ | ||
Number: errno, | ||
|
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.
Please put a space between `// and the comment.
Slightly changed comment: "The MariaDB server sends a packet with sequence number 0 when the server is shutdown."