onboard transaction.exs suite, various transaction fixes#112
Merged
warmwaffles merged 2 commits intomainfrom Mar 17, 2021
Merged
onboard transaction.exs suite, various transaction fixes#112warmwaffles merged 2 commits intomainfrom
warmwaffles merged 2 commits intomainfrom
Conversation
…y rollingback when closing connection, onboard transaction.exs tests
warmwaffles
approved these changes
Mar 17, 2021
Member
warmwaffles
left a comment
There was a problem hiding this comment.
Interesting find. Thank you for leaving that note there.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The main test that was failing was this one, which was subsequently blocking the other tests was:
We assume that all transaction-beginning statements go through our
handle_transactioncall which is not the case. Here we don't detect we begin a transaction and thus don't know we are in an active transaction at "checkin" time, hence why the error is not thrown.The fix is to add a new
transaction_statusNIF call that uses http://www.sqlite.org/c3ref/get_autocommit.html to return the current transaction status, and wiring that up in the correct places.The second issue was that
:disconnectwas not properly rolling back a transaction. This is becausesqlite3_close_v2is not guaranteed to succeed, and indeed was going into a "zombie" state, as described at https://www.sqlite.org/c3ref/close.html . The fix for this was to make sure we atleast roll back any active transaction before doing this close logic, and then relying on the GC to clean the open prepared statements.This closes #93 and likely also closes #58 .