-
Notifications
You must be signed in to change notification settings - Fork 245
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
driver-adapters: remove dispose method for JS transaction interface #4489
Merged
aqrln
merged 9 commits into
main
from
driver-adapters-remove-dispose-method-for-js-transaction-interface
Nov 27, 2023
Merged
Changes from 6 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
4103f85
driver-adapters: remove dispose method for JS transaction interface
aqrln 71e54b4
Use store instead of swap
aqrln 6cde7b1
Add test
aqrln 5f72dde
Only run test with driver adapters
aqrln a66a019
Change order of operations in commit and rollback
aqrln 5ab9f4f
Clarify wording a bit
aqrln 3948956
Change `only` tag from generic `JS` to `libsql.js`
aqrln 96e9ec8
Relax ordering mode of `TransactionProxy::closed` modifications
aqrln 8e0f716
Fix the exclude tag
aqrln File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,3 +27,4 @@ mod prisma_7010; | |
mod prisma_7072; | ||
mod prisma_7434; | ||
mod prisma_8265; | ||
mod prisma_engines_4286; |
24 changes: 24 additions & 0 deletions
24
...ine/connector-test-kit-rs/query-engine-tests/tests/new/regressions/prisma_engines_4286.rs
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
use query_engine_tests::*; | ||
|
||
#[test_suite(schema(generic), only(JS, Sqlite))] | ||
aqrln marked this conversation as resolved.
Show resolved
Hide resolved
|
||
mod sqlite { | ||
#[connector_test] | ||
async fn close_tx_on_error(runner: Runner) -> TestResult<()> { | ||
// Try to open a transaction with unsupported isolation error in SQLite. | ||
let result = runner.start_tx(2000, 5000, Some("ReadUncommitted".to_owned())).await; | ||
assert!(result.is_err()); | ||
|
||
// Without the changes from https://github.com/prisma/prisma-engines/pull/4286 or | ||
// https://github.com/prisma/prisma-engines/pull/4489 this second `start_tx` call will | ||
// either hang infinitely with libSQL driver adapter, or fail with a "cannot start a | ||
// transaction within a transaction" error. | ||
// A more future proof way to check this would be to make both transactions EXCLUSIVE or | ||
// IMMEDIATE if we had control over SQLite transaction type here, as that would not rely on | ||
// both transactions using the same connection if we were to pool multiple SQLite | ||
// connections in the future. | ||
let tx = runner.start_tx(2000, 5000, None).await?; | ||
runner.rollback_tx(tx).await?.unwrap(); | ||
aqrln marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
Ok(()) | ||
} | ||
} |
This file contains 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
This file contains 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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JS-only because after adding the test turned out that it's actually broken with native SQLite connector, this scenario has never been tested before (except indirectly via smoke tests for driver adapters which uncovered the issue back then):
I'll open an issue with TypeScript reproduction, and we can fix it separately.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fix might be to move the logic added in this PR somewhere to the level above, let me know if you'd prefer it to be done in this PR rather than separately.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that should maybe be blanket Drop for Transaction from quaint? If that's easy enough to do, then I'd prefer to do it here and fix the issue for all driver, otherwise follow-up should be fine too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately this violates orphan rules, and if it didn't, the fact that we also need some state and not just the Drop impl could make this a little awkward. I think it would be better to wrap the quaint transaction into some struct that will take care of this. Let's do that as a follow-up so we can land this PR already.