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

Remove shard session held in vtgate for reserved connection on connection failure #6522

Merged
merged 7 commits into from
Aug 13, 2020

Conversation

harshit-gangal
Copy link
Member

When a reserved connection is used in transaction it is natural to call rollback/commit when a query execution failed.
But, when a reserved connection is used in non-transaction/autocommit mode, VTGate needs to handle to case to release the held reserved connection in session, to move forward on next query and recreate the reserved connection with correct settings.

@harshit-gangal harshit-gangal requested a review from sougou July 31, 2020 18:23
@harshit-gangal harshit-gangal marked this pull request as ready for review July 31, 2020 20:23
Copy link
Contributor

@sougou sougou left a comment

Choose a reason for hiding this comment

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

I think it's ok to keep the connection. Otherwise, we'll start churning connections on things like syntax error, etc. Was there a use case where keeping the connection would be harmful?

@harshit-gangal
Copy link
Member Author

I think it's ok to keep the connection. Otherwise, we'll start churning connections on things like syntax error, etc. Was there a use case where keeping the connection would be harmful?

In a transaction, when a connection is closed/lost, server expectation is to receive commit/rollback.
In case of reserved connection and not in a transaction, a connection when closed/lost needs to be renewed on getting error from tabletserver otherwise the client will keep sending the query to errored reserved connection.

Currently, the reset happens only for below two mysql error codes.

sqlErr := mysql.NewSQLErrorFromError(err).(*mysql.SQLError)
if sqlErr.Number() == mysql.CRServerGone || sqlErr.Number() == mysql.CRServerLost {
   session.ResetShard(info.alias)
}

@harshit-gangal
Copy link
Member Author

// CRServerGone is CR_SERVER_GONE_ERROR.
// This is returned if the client tries to send a command but it fails.
CRServerGone = 2006

// CRServerLost is CR_SERVER_LOST.
// Used when:
// - the client cannot write an initial auth packet.
// - the client cannot read an initial auth packet.
// - the client cannot read a response from the server.
CRServerLost = 2013

We should also look at the list of what other possible error codes which says that the server connection is no longer valid.

@deepthi deepthi modified the milestone: 7.0.1 Aug 11, 2020
go/vt/vtgate/scatter_conn.go Outdated Show resolved Hide resolved
Signed-off-by: Harshit Gangal <harshit@planetscale.com>
… failure

Signed-off-by: Harshit Gangal <harshit@planetscale.com>
Signed-off-by: Harshit Gangal <harshit@planetscale.com>
Signed-off-by: Harshit Gangal <harshit@planetscale.com>
Signed-off-by: Harshit Gangal <harshit@planetscale.com>
Signed-off-by: Harshit Gangal <harshit@planetscale.com>
Signed-off-by: Harshit Gangal <harshit@planetscale.com>
@harshit-gangal harshit-gangal force-pushed the reservedconn-closedconn branch from 2ceae0c to 580f805 Compare August 13, 2020 17:03
@harshit-gangal harshit-gangal merged commit 0ca6e69 into vitessio:master Aug 13, 2020
@harshit-gangal harshit-gangal deleted the reservedconn-closedconn branch August 13, 2020 18:17
@askdba askdba added this to the v8.0 milestone Oct 5, 2020
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.

4 participants