Skip to content

vttablet mysql conn improvements#3933

Merged
demmer merged 4 commits intovitessio:masterfrom
tinyspeck:vttablet-mysql-conn-improvements
May 17, 2018
Merged

vttablet mysql conn improvements#3933
demmer merged 4 commits intovitessio:masterfrom
tinyspeck:vttablet-mysql-conn-improvements

Conversation

@demmer
Copy link
Copy Markdown
Collaborator

@demmer demmer commented May 16, 2018

Add a couple of changes to improve visibility and robustness on the vttablet => mysql connection handling.

  1. Add timing stats for successful / failed calls to Connect to mysql.

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.

  1. Check that the context deadline hasn't expired before running a query

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.

demmer added 2 commits May 15, 2018 17:06
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>
@demmer demmer requested a review from sougou May 16, 2018 00:28
@demmer
Copy link
Copy Markdown
Collaborator Author

demmer commented May 16, 2018

NB: I added simple unit tests but haven't yet tested this in a real environment. Will do that tomorrow.

Copy link
Copy Markdown
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.

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 {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This check is not needed. If the channel is nil, it won't fire.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Thanks -- removed (and verified it still works)

@demmer
Copy link
Copy Markdown
Collaborator Author

demmer commented May 16, 2018 via email

demmer added 2 commits May 15, 2018 18:00
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>
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.

2 participants