-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
support COM_RESET_CONNECTION to reset session #1273
Comments
It will kill performance. Why do you need it? |
Emmm, that's a big story. I hope to gracefully shutdown a database(not only for mysql but for some mysql protocol compatible server, such as TiDB), but I find it that only client side knows when to close TCP connections. Now
I hope
While server is marked as shutting down, response of The performance of one instance is not an important problem(can be resolved by scaling). And this feature can be optional for performance sensitive scenario. And some mysql pools such as https://github.com/mysql/mysql-connector-python has implemented this feature.(a question about this feature: https://dba.stackexchange.com/questions/290727/when-and-why-should-i-reset-session-in-a-connection-pool) Sorry for my poor English, I'm not sure the reason is clearly explained. |
You should try |
If |
Have you really tried it? 3sec? 5sec? how much overhead? MySQL connection is relatively cheap. I think it is much cheaper than sending |
Not for every query, but when putting conn back to pool. And I think COM_RESET_CONNECTION < COM_CHANGE_USER < reconnect
|
Connection pool is designed to avoid the handshake time of mysql connection. If |
Of course, but it is much more frequent. |
If your app sends 500query/sec, 1500 queries can be sent in 3sec lifetime. |
And if it is unacceptable for you, you can use both of ConnMaxIdleTime and ConnMaxLifetime. |
Good point, I never really assume such short of lifetime(normally maxlifetime is X mins). And shutdown time above 30s is hardly acceptable(default in kubernetes is 30s). I'll reconsider it and may test it by the real world data. |
I change my mind, an arbitrary lifetime is acceptable and enough. What I really need is changing the timeout of graceful shutdown. |
Provide a hook or a option for user to send COM_RESET_CONNECTION can avoid session variable leaked. It do may be needed in some scenes. Someone need while many don't need, let user decide it. |
I have seen code that assumes session variables will leak. It just happens to work, but it is incorrect. I think it would be useful to avoid such code. |
Issue description
Now
ResetSession
only mark a flag. It's more reasonable to sendCOM_RESET_CONNECTION
to really reset session.https://dev.mysql.com/doc/internals/en/com-reset-connection.html
Example code
Error log
Configuration
Driver version (or git SHA):
Go version: run
go version
in your consoleServer version: E.g. MySQL 5.6, MariaDB 10.0.20
Server OS: E.g. Debian 8.1 (Jessie), Windows 10
The text was updated successfully, but these errors were encountered: