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

vttablet: don't shutdown on too many connections #7039

Merged
merged 1 commit into from
Nov 16, 2020

Conversation

sougou
Copy link
Contributor

@sougou sougou commented Nov 14, 2020

Fixes #7038

This change makes IsConnErr treat "Too many connections" as a normal
error, allowing vttablet to continue serving. The same check is also
added to IsMySQLReachable in case it happens to get called through
a different code path.

The error code returned by mysql (2012) is more generic. So, we also
have to check for the specific substring.

It's hard to reliably test this using automated testing. Instead, I
manually created a state where mysql ran out of connections, verified
that vttablet did shut down, and also verified that vttablet continued
to serve after this fix.

Signed-off-by: Sugu Sougoumarane ssougou@gmail.com

Fixes vitessio#7038

This change makes IsConnErr treat "Too man connections" as a normal
error, allowing vttablet to continue serving. The same check is also
added to IsMySQLReachable in case it happens to get called through
a different code path.

The error code returned by mysql (2012) is more generic. So, we also
have to check for the specific substring.

It's hard to reliably test this using automated testing. Instead, I
manually created a state where mysql ran out of connections, verified
that vttablet did shut down, and also verified that vttablet continued
to serve after this fix.

Signed-off-by: Sugu Sougoumarane <ssougou@gmail.com>
@harshit-gangal harshit-gangal merged commit 1fa400a into vitessio:master Nov 16, 2020
@harshit-gangal harshit-gangal deleted the ss-vt1-max-conns branch November 16, 2020 12:50
@harshit-gangal harshit-gangal added this to the v9.0 milestone Nov 16, 2020
// IsTooManyConnectionsErr returns true if the error is due to too many connections.
func IsTooManyConnectionsErr(err error) bool {
if sqlErr, ok := err.(*SQLError); ok {
if sqlErr.Number() == CRServerHandshakeErr && strings.Contains(sqlErr.Message, "Too many connections") {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: string literal should be made into a constant.

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

Successfully merging this pull request may close these issues.

vttablet should not shutdown on "Too many connections" error
4 participants