-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
vtcombo: close query service on drop database #16606
vtcombo: close query service on drop database #16606
Conversation
Signed-off-by: Brendan Dougherty <[email protected]>
Review ChecklistHello reviewers! 👋 Please follow this checklist when reviewing this Pull Request. General
Tests
Documentation
New flags
If a workflow is added or modified:
Backward compatibility
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #16606 +/- ##
==========================================
+ Coverage 68.85% 68.98% +0.12%
==========================================
Files 1557 1562 +5
Lines 199891 200693 +802
==========================================
+ Hits 137644 138457 +813
+ Misses 62247 62236 -11 ☔ View full report in Codecov by Sentry. |
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.
Thanks, @brendar ! This change makes sense to me there:
err := tablet.qsc.QueryService().Close(ctx)
We should, however, add some kind of test that demonstrates the problem on main and in turn verifies that it's been fixed in the PR branch.
Signed-off-by: Brendan Dougherty <[email protected]>
@mattlord I've added assertions to the vtcombo recreate test. It fails on main:
When testing the fix locally I sometimes saw a difference of 1 connection before and after, which I believe is due to some short lived or lazily initialized connection, so I gave it what I think is a pretty wide delta (5 connections). The alternative to counting connections would be to parse the |
} | ||
|
||
func getMySQLConnectionCount(ctx context.Context, session *vtgateconn.VTGateSession) (int, error) { | ||
result, err := session.Execute(ctx, "SELECT COUNT(*) FROM information_schema.processlist", nil) |
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.
IMO this is a better query as the process list will show internal threads too (and it's deprecated 🙂):
mysql> show processlist;
+----+-----------------+-----------------+-------------+------------------+------+-----------------------------------------------------------------+------------------+
| Id | User | Host | db | Command | Time | State | Info |
+----+-----------------+-----------------+-------------+------------------+------+-----------------------------------------------------------------+------------------+
| 5 | event_scheduler | localhost | NULL | Daemon | 467 | Waiting on empty queue | NULL |
| 13 | vt_dba | localhost | NULL | Sleep | 1 | | NULL |
| 23 | vt_dba | localhost | vt_commerce | Sleep | 462 | | NULL |
| 24 | vt_app | localhost | vt_commerce | Sleep | 463 | | NULL |
| 26 | vt_allprivs | localhost | vt_commerce | Sleep | 463 | | NULL |
| 27 | vt_repl | 127.0.0.1:50890 | NULL | Binlog Dump GTID | 463 | Source has sent all binlog to replica; waiting for more updates | NULL |
| 28 | vt_repl | 127.0.0.1:50889 | NULL | Binlog Dump GTID | 463 | Source has sent all binlog to replica; waiting for more updates | NULL |
| 32 | vt_app | localhost | vt_commerce | Sleep | 23 | | NULL |
| 39 | vt_app | localhost | vt_commerce | Sleep | 461 | | NULL |
| 42 | root | localhost | vt_commerce | Query | 0 | init | show processlist |
+----+-----------------+-----------------+-------------+------------------+------+-----------------------------------------------------------------+------------------+
10 rows in set, 1 warning (0.00 sec)
mysql> show warnings;
+---------+------+-------------------------------------------------------------------------------------------------------------------------------------------+
| Level | Code | Message |
+---------+------+-------------------------------------------------------------------------------------------------------------------------------------------+
| Warning | 1287 | 'INFORMATION_SCHEMA.PROCESSLIST' is deprecated and will be removed in a future release. Please use performance_schema.processlist instead |
+---------+------+-------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
mysql> select variable_value from performance_schema.global_status where variable_name="threads_connected";
+----------------+
| variable_value |
+----------------+
| 9 |
+----------------+
1 row in set (0.00 sec)
row := result.Rows[0][0] | ||
toInt, err := row.ToInt() | ||
if err != nil { | ||
return 0, err | ||
} | ||
return toInt, nil |
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.
Nit, but you can do all of this together:
return result.Rows[0][0].ToInt()
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.
👍 I'm assuming that this fails on main? I think that's what your comment was demonstrating but just triple checking.
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.
Yes, it fails on main.
Signed-off-by: Brendan Dougherty <[email protected]>
@mattlord Thanks for the thoughtful review. Comments have been addressed and I've confirmed the test still fails on main. |
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.
Thanks, @brendar !
Signed-off-by: Brendan Dougherty <[email protected]>
Signed-off-by: Brendan Dougherty <[email protected]>
Description
Closes the query service on
DROP DATABASE
, which will close connection pools.Related Issue(s)
Fixes #16605
Checklist
Deployment Notes