-
Notifications
You must be signed in to change notification settings - Fork 2.3k
QueryContext() timeout can kill the db connection, but ExecContext() can't #1171
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
Comments
This is not difference between Query and Exec. MySQL detects connection closed from client during sleep, but not during regular query. See #731, and See #731 (comment) for workaround. |
Really appreciate! two questions:
|
I don't have any reference. This is just my observations. I tested many MySQL behaviors by myself.
I don't know. But before the RST, MySQL server sent FIN, ACK to client in QueryContext. On the other hand, MySQL server didn't send FIN, ACK (because query is not sleep). That's why TCP connection is alive. |
@methane very thanks! |
Issue description
Tell us what should happen and what happens instead
I pass a timeout context to QueryContext(), then execute a long time running query sql. When the ctx timeout, QueryContext() return err, and the db connection is killed and missing from 'show processlist'.
Then I pass a timeout context to ExecContext(), execute a long time running sql. When the ctx timeout, ExecContext() return err, but the sql is still running and the db connection also exists in 'show processlist'.
Example code
Error log
Configuration
Driver version (or git SHA):
github.com/go-sql-driver/mysql v1.5.0
Go version: run
go version
in your consolego1.14.2 darwin/amd64
Server version: E.g. MySQL 5.6, MariaDB 10.0.20
MySQL 5.7.17
Server OS: E.g. Debian 8.1 (Jessie), Windows 10
macOS Catalina
The text was updated successfully, but these errors were encountered: