Skip to content
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

fix: respect isolation level parameter and defaults #5056

Merged
merged 9 commits into from
Nov 27, 2024

Conversation

jacek-prisma
Copy link
Contributor

@jacek-prisma jacek-prisma commented Nov 26, 2024

Fixes a few things:

  • start_transaction was not being dispatched correctly in a few places because Quaint had an impl that was bypassing the impl of the inner type
  • I rewrote the mssql_transaction_isolation_level test to capture that the isolation level parameter is respected and that isolation level changes do not linger for more than 1 transaction when left unspecified

@jacek-prisma jacek-prisma requested a review from a team as a code owner November 26, 2024 17:14
@CLAassistant
Copy link

CLAassistant commented Nov 26, 2024

CLA assistant check
All committers have signed the CLA.

Copy link

codspeed-hq bot commented Nov 26, 2024

CodSpeed Performance Report

Merging #5056 will not alter performance

Comparing jacek-prisma:isolation-level-fixes (7098ead) with main (c1f5600)

Summary

✅ 11 untouched benchmarks

Copy link
Member

@aqrln aqrln left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome work and investigation, let's have it fixed for the pooled connections as well since it seems to be a real bug that affects the ORM and not just the tests.

quaint/src/single.rs Show resolved Hide resolved
@jacek-prisma jacek-prisma changed the title Isolation level fixes fix: respect isolation level parameter and defaults Nov 27, 2024
@@ -112,6 +112,7 @@ pub trait TransactionCapable: Queryable {
) -> crate::Result<Box<dyn Transaction + 'a>>;
}

#[cfg(any(feature = "mssql-native", feature = "postgresql-native", feature = "mysql-native"))]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be

Suggested change
#[cfg(any(feature = "mssql-native", feature = "postgresql-native", feature = "mysql-native"))]
#[cfg(any(feature = "sqlite-native", feature = "postgresql-native", feature = "mysql-native"))]

?

Copy link
Contributor Author

@jacek-prisma jacek-prisma Nov 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, I think it should have all the connectors, I was testing with the WASM build specifically, but I think not including sqlite here causes errors in other platform builds

@@ -130,4 +131,5 @@ macro_rules! impl_default_TransactionCapable {
};
}

#[cfg(any(feature = "mssql-native", feature = "postgresql-native", feature = "mysql-native"))]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

@@ -29,6 +30,16 @@ pub(crate) struct TransactionOptions {
pub(crate) isolation_first: bool,
}

#[cfg(any(feature = "mssql-native", feature = "postgresql-native", feature = "mysql-native"))]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should probably be enabled for all four connectors

@@ -83,6 +83,10 @@ impl<'a> TestApi for Sqlite<'a> {
Quaint::new(CONN_STR).await
}

fn create_pool(&self) -> crate::Result<crate::pooled::Quaint> {
Ok(crate::pooled::Quaint::builder(CONN_STR)?.build())
Copy link
Member

@aqrln aqrln Nov 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could probably add a method that returns the connection string and move the implementation to the trait itself to reduce some duplication. No need to change anything, it is totally fine as is and is consistent with create_additional_connection and other methods, I'm just thinking out loud and wondering if it might be worth it to de-duplicate a bunch of stuff here generally.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've had the same idea, but I wasn't sure if putting the connection string on the trait leaks too much of an internal detail

Comment on lines +130 to +135
// We want to verify that pooled connection behaves the same way, so we test both cases.
let pool = api.create_pool()?;
for conn_b in [
Box::new(pool.check_out().await?) as Box<dyn TransactionCapable>,
Box::new(api.create_additional_connection().await?),
] {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice!

Copy link
Member

@aqrln aqrln left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice work!

@jacek-prisma jacek-prisma merged commit 0160cc2 into prisma:main Nov 27, 2024
368 checks passed
jacek-prisma added a commit to jacek-prisma/prisma that referenced this pull request Nov 28, 2024
jacek-prisma added a commit to jacek-prisma/prisma that referenced this pull request Nov 28, 2024
@jacek-prisma jacek-prisma deleted the isolation-level-fixes branch November 28, 2024 10:04
jkomyno pushed a commit to prisma/prisma that referenced this pull request Nov 28, 2024
…ines#5056 (#25745)

* chore(deps): update engines to 5.23.0-21.0160cc2f56997459423712af8dfa8cf1ad97704b

* fix: update tests to account for a sqlserver fix in prisma/prisma-engines#5056

Signed-off-by: Jacek Malec <[email protected]>

* fix: further fixes related to mssql isolation level

* refactor: minor test cleanups

* fix: revert deletion of eslint-disable line

* refactor: minor test cleanup

* fix: re-add eslint-disable and update the lint stage commit not to write files

---------

Signed-off-by: Jacek Malec <[email protected]>
Co-authored-by: Prismo <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants