vttablet mysql conn improvements#3933
Merged
demmer merged 4 commits intovitessio:masterfrom May 17, 2018
Merged
Conversation
In order to better monitor how many times the tablet creates a new mysql connection and how long these attempts take, add another call to measure the timings of each Connect operation in the dbconn wrapper. Additionally record the timings and associated counts for any times when the connection to mysql fails to execute the handshake. Signed-off-by: Michael Demmer <mdemmer@slack-corp.com>
If the context deadline expires before the query has a chance to execute, the query killer will terminate the connection immediately after sending the query to mysql. Instead, add a check at the start of dbConn.execOnce and fail the query immediately if the context is already past the deadline. Signed-off-by: Michael Demmer <mdemmer@slack-corp.com>
Collaborator
Author
|
NB: I added simple unit tests but haven't yet tested this in a real environment. Will do that tomorrow. |
sougou
reviewed
May 16, 2018
Contributor
sougou
left a comment
There was a problem hiding this comment.
Change is good. One minor comment.
|
|
||
| // Check if the context is already past its deadline before | ||
| // trying to execute the query. | ||
| if ctx.Done() != nil { |
Contributor
There was a problem hiding this comment.
This check is not needed. If the channel is nil, it won't fire.
Collaborator
Author
There was a problem hiding this comment.
Thanks -- removed (and verified it still works)
Collaborator
Author
|
Oh. I copied that from other parts of the code.
…-m
On May 15, 2018, at 5:36 PM, Sugu Sougoumarane ***@***.***> wrote:
@sougou commented on this pull request.
Change is good. One minor comment.
In go/vt/vttablet/tabletserver/connpool/dbconn.go:
> @@ -132,6 +132,16 @@ func (dbc *DBConn) execOnce(ctx context.Context, query string, maxrows int, want
dbc.current.Set(query)
defer dbc.current.Set("")
+ // Check if the context is already past its deadline before
+ // trying to execute the query.
+ if ctx.Done() != nil {
This check is not needed. If the channel is nil, it won't fire.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
As suggested in PR review there's no need for the extra check that ctx.Done() is none nil before selecting from it. Signed-off-by: Michael Demmer <mdemmer@slack-corp.com>
Previously it included all counts in the MySQLStats which now also tracks connections. Signed-off-by: Michael Demmer <mdemmer@slack-corp.com>
sougou
approved these changes
May 16, 2018
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add a couple of changes to improve visibility and robustness on the vttablet => mysql connection handling.
In order to better monitor how many times the tablet creates a new mysql connection and how long these attempts take, add another call to measure the timings of each Connect operation in the dbconn wrapper.
Additionally record the timings and associated counts for any times
when the connection to mysql fails to execute the handshake.
If the context deadline expires before the query has a chance to execute, the query killer will terminate the connection immediately after sending the query to mysql.
Instead, add a check at the start of dbConn.execOnce and fail the query immediately if the context is already past the deadline.