-
-
Notifications
You must be signed in to change notification settings - Fork 28
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
Begin/ End transaction - fails on the commit #79
Comments
I don't understand what's exactly the problem you have. |
Sure happy to.
Then run this test code:
If begin and commit where pairs, then I would expect that the following query run on MySQL would return the new id and data. Instead looking at the outstanding transactions shows that there is still an open transaction: The with-transaction approach does work
The query directly on MySQL shows the new pair inserted into the table as expected. this is because with-transaction uses the with-savepoint code. This code of course leaks connections. A fuller implementation would hand the connection to the functions and maintain them in a cache. |
Thank you for your explanation. I never thought of using It'd be better to make it work since it's not an intuitive behavior. |
I ran into this because other packages I've used in other languages typically work the way I used dbi. Its also consistent with how the SQL is designed within the databases. That said dbi:with-transaction is very convenient and works correctly. I would suggest that the simplest solution is to either document that begin-transaction, commit, and rollback only work within the context of a save-point with an example or remove all of these functions from the API. MySQL does not support nested transactions but it can be implemented with save-points so that is the one case where controlling the save points is useful. |
I believe I've found a base issues on the code for transactions. I"m working on MySQL 8 and the following sequence:
(begin-transaction conn)
(query conn "insert...")
(commit conn)
Ends up with MySQL holding an open transaction on the connection thread.
I believe the bug is in driver.lisp in the begin-transaction code. The code for commit checks the variable transaction-state using the method get-transaction-state . This is returning _n_il so the when clause simply falls through and the call-next-method is never called (which would actually issue the commit).
The reason appears to begin-transaction never adds a cons to this variable which does happen in %with-transaction. This could be set with with-savepoint. Is that the required process? If so the documentation should be updated. Otherwise this is a bug.
Rollback has the same issue as Commit.
The text was updated successfully, but these errors were encountered: