-
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
fix(driver-adapters): support Transaction Isolation Levels in PlanetScale #4966
Conversation
…ma-engines into fix/planetscale-transactions
WASM Query Engine file Size
|
CodSpeed Performance ReportMerging #4966 will not alter performanceComparing Summary
|
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 am really not sure about that.
client.execute
is not guaranteed to be executed on the same connection transaction will later start and it only works it tests because there are no concurrent requests.
And since we are not making a change on the adapter level, but on the driver itself - it is definietely not guaranteed that for any potential mysql adapter executeRaw
and startTransaction
are executed on the same connection.
I think the way we should do it instead is:
- change
startTransaction
in driver interface to accept isolation level. This is how I originally implemented it, and then we changed it for logging' sake and I think this was a mistake. - now driver is responsible for both starting the transaction and setting isolation level.
- in planetscale driver, we can now first secure the connection (IIRC, they have a session api for that), set isolation level and only then start the transaction.
You raised a good point, but I think we can use the {
const conn = await client.connection()
await conn.execute('SET TRANSACTION ISOLATION LEVEL SERIALIZABLE')
await conn.transaction(async (tx) => {
// ...
})
} What do you think? |
From what I can see, implementing this means:
|
Sorry, I don't quite see how that would work without refactor I am suggesting, can you clarify a bit? |
Deprecated by #4967 and prisma/prisma#24878. |
This PR:
Explanation
We originally thought that Transaction Isolation Levels for PlanetScale worked fine in TypeScript-land, and only failed in Rust tests with the error message:
As it turns out, that wasn't the case: there were actual issues in the way we were executing
SET TRANSACTION ISOLATION LEVEL ...
queries.Consider the following snippet, constructing a
planetScale.Client
instance:Before this PR, using transactions with custom isolation levels in
@prisma/adapter-planetscale
was virtually equivalent to:This results in a runtime error. As written in the MySQL docs,
So, this PR changes the
driver-adapters
part of Query Engine to trigger the following JS logic instead: