-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Weird behaviour with query cancellation using context #863
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
We are encountering weird behaviour. When we run the Go code above, the context is cancelling after 3 seconds -- all good. |
Now, if we change the stored proc so that it's:
The Go code works perfectly and cancels the query (i.e. no insertion happens). But in our Go code, the second stored proc works but the first does not - leading to our belief that there is some weird bug in the driver. |
It's not a bug. We don't support cancelling query yet. |
The Readme: https://github.com/go-sql-driver/mysql#contextcontext-support
|
OK, README is misleading. It just cancelling "waiting" query result, not query execution. MySQL protocol doesn't provide safe way to cancel query execution. |
thanks |
What you should do is using transaction. If you don't commit, it's rollbacked. |
Why does first storedProc insert after timeout but second storedProc does not insert. I'd assume that based on your statement, it either inserts or it doesn't. If the driver doesn't support cancelling query execution, why does it seem to cancel the execution? |
It's MySQL behavior. I don't know much. But SLEEP() has very strange behavior when connection is closed. |
@julienschmidt what do you think of this idea: src-d/gitbase-web#241 (comment) |
Unfortunately that can't be implemented on the driver level easily. It would require a 2nd connection on which the driver executes these commands. That could be either a shared "management connection" or connections opened on demand. First of all, this would make the driver much more complex. Right now all the handling of sessions and connections is done by the But much more problematic is, that we have actually no way to find the right server (unless there is just one). The driver is largely deployed with mysql load-balancing proxies. In that case, it is likely hat |
Would you be able to make a Go 2 proposal to modify what ever is required to |
I honestly think that not A good start would be if the reply to queries sent to the server would contain the process id. In the case of a single server setup, we could then cancel queries in a similar manner to Postgres: Open a new connection and immediately send the The case with some proxy is more difficult. Right now such proxies are completely transparent to the driver. What would be required is some sort of mechanism to guarantee that a connection is opened to the same backend as another existing connection. |
We actually have an open PR for a similar approach (for the single server setup case) already: #791 |
I'm going to submit a feature request with MySQL. If I ask for queries to contain the process id, would that create a backwards-incompatible change that they will flat out refuse? |
It's the not only problem about cancelling. There are some other issues. Anyway, what is the point of this issue? If we really need issue for "Implement cancelling query", file an new issue and close this. |
Here is my solution: https://medium.com/@rocketlaunchr.cloud/canceling-mysql-in-go-827ed8f83b30 |
Server: MySQL 5.6
Stored Proc:
Go Code:
The text was updated successfully, but these errors were encountered: