-
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
statements in context cancelled transaction still getting committed #1010
Comments
I think there is nothing we can do here. |
Is there anything we can do to detect and mitigate cases where the library violates its contract and makes simultaneous calls to the driver? Here's a real trace from my system which ends in disaster, when tx.Rollback is called (by the database/sql library) in the middle of stmt.ExecContext. The rollback fails with a busy buffer error, but not before resetting the sequence number and fatally confusing the effort to read the result set. Ultimately, the standard library will need to be fixed, but it would make the impact less severe if the mysql driver were able to protect itself.
|
golang/go#34775 has been fixed. |
Issue description
It is possible to execute statements in a transaction which has been aborted via cancelled context, and have those statements commit.
Basically, in response to context cancellation, the library calls
Tx.Rollback
Stmt.ExecContext
Conn.Close
It should not be possible to execute a statement after the transaction has been rolled back, and in fact because of mysql's autocommit default, the statement will surprisingly commit.
See golang/go#34775.
While it looks like a database/sql bug, I wonder if there's something that can be done to mitigate on the driver side.
Example code
https://gist.github.com/dadkins-at-dropbox/5b051b9ccb30f115c332c6037d03d63d
Error log
Configuration
Driver version (or git SHA):
14bb9c0
Go version: run
go version
in your consolego version go1.13.1 darwin/amd64
Server version: E.g. MySQL 5.6, MariaDB 10.0.20
Server version: 8.0.17 Homebrew
Server OS: E.g. Debian 8.1 (Jessie), Windows 10
(I also see the problem on Linux against mysql 5.7)
The text was updated successfully, but these errors were encountered: